copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

JSON-formatted output

Open mark-undoio opened this issue 3 months ago • 3 comments

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 -p flag to supply a task) - output can be parsed using jq or 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

mark-undoio avatar Sep 26 '25 10:09 mark-undoio

Great suggestion, thanks @mark-undoio.

SteveSandersonMS avatar Sep 26 '25 13:09 SteveSandersonMS

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.

mark-undoio avatar Nov 10 '25 11:11 mark-undoio

This is a super important feature to have.

santiago-afonso avatar Nov 25 '25 16:11 santiago-afonso

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.

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

DTW-DanWard avatar Dec 14 '25 15:12 DTW-DanWard