Skip to content

Implement agent-trace standard for event emission and observability #1275

@nkyriakidis

Description

@nkyriakidis

Describe the feature or problem you'd like to solve

Implement agent-trace standard for event emission and observability

Proposed solution

The GitHub Copilot CLI currently operates largely as a "black box"—users input natural language and receive a command, with limited visibility into the specific context usage or reasoning steps involved.

I propose adopting the agent-trace standard (https://github.com/cursor/agent-trace) to optionally emit structured lifecycle events.

Benefits:

  • Interoperability: Allows third-party terminal tools, IDEs, and shells to visualize Copilot's "thinking" process (e.g., creating a visualization of the prompt construction and response parsing).
  • Debugging: Helps power users and contributors understand why a specific command was suggested by inspecting the raw trace events (Input -> Reasoning -> Output).
  • Auditing: Provides a standardized JSON format for enterprises to log exactly how shell commands are being generated and what context was retrieved.

Example prompts or workflows

Debugging a hallucination: Running gh copilot suggest "deploy to k8s" --trace would output the standard command suggestion to stdout, but write a agent-trace compatible JSON file to a temp directory or stderr. The user can inspect this JSON to see that the model failed to detect the local kubectl context.

IDE/Terminal Integration: A terminal emulator (like Warp or Ghostty) could wrap the Copilot CLI execution. By listening to the agent-trace events, the terminal could display a real-time status indicator ("Analyzing shell history...", "Generating command...") rather than a static spinner.

Audit Logging: A security-conscious developer sets an environment variable COPILOT_TRACE_DIR=/var/log/copilot. Every time they run gh copilot explain, a trace file is saved containing the exact prompt sent and the raw model completion, allowing for post-incident review if a dangerous command was executed.

Additional context

Reference: https://github.com/cursor/agent-trace

Implementation note: Since the CLI is often used in pipes or with eval, trace output should likely be directed to stderr, a specific file path, or a side-channel, ensuring it does not corrupt the standard output intended for execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions