JSON-formatted output
Describe the feature or problem you'd like to solve
A structured output mode to easily consume the output in other tools.
Proposed solution
My proposed solution is something similar to:
- Claude Code's
--output-format stream-json - Codex CLI's
--json
The above tools provide their output in JSONL format with each interaction (tool use, assistant messages, etc) being supplied in an easily-parsed JSON format.
This makes integration with external tools simpler, allowing the agentic functionality of copilot to be easily used from scripts, third-party tools, etc.
Example prompts or workflows
- Integration with ad-hoc scripting (combined with the existing
-pflag to supply a task) - output can be parsed usingjqor similar to receive results or error codes. - Integration with 3rd-party tools - output can be parsed and presented in the native interface of that tool, making it easier to integrate well with the Copilot AI ecosystem.
- Automated testing - make it easier to parse and reason about the output when evaluating prompts or testing MCP integrationsl.
Additional context
No response
Great suggestion, thanks @mark-undoio.
Another thing that I'd like to flag explicitly on this whilst I'm thinking about it:
If the JSON output could explicitly supply the session ID (and probably cost stats, etc etc) at the end it would help 3rd party tools manage integrations.
Currently I'm creating a temporary XDG_STATE_HOME directory so that --resume will join up with each subsequent invocation of copilot -p. If I had easy access to session ID in the output I would be able to eliminate that code and just pass the session ID to --resume directly.
This is a super important feature to have.
Another thing that I'd like to flag explicitly on this whilst I'm thinking about it:
If the JSON output could explicitly supply the session ID (and probably cost stats, etc etc) at the end it would help 3rd party tools manage integrations.
Currently I'm creating a temporary
XDG_STATE_HOMEdirectory so that--resumewill join up with each subsequent invocation ofcopilot -p. If I had easy access to session ID in the output I would be able to eliminate that code and just pass the session ID to--resumedirectly.
Having session id in the json output would help make the --resume <session-id> param safe and easy and solve these types of issues:
https://github.com/github/copilot-cli/issues/442