← Back to Pull requests

fix: record VS Code Copilot tool output and slim the raw audit event #48

Open
unknown opened this pull request with 356 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 12, 2026 15:52 UTC
Author

Problem

Two problems in the local-agent audit hook, found while investigating obot-platform/obot#8420:

  • VS Code tool output is not recorded. VS Code's Copilot harness (which Copilot CLI shares) reports output as tool_result: {result_type, text_result_for_llm} and sends no tool_response. The parser only read tool_response, so these events were submitted with response.body: null. The output survived only inside rawEvent.

  • The raw event repeats the tool input and output. Every entry submits tool_input and the tool output in their own fields, and then again inside rawEvent, which is the hook's whole stdin. For Claude Code those two values are about 88% of the payload.
  • Change

  • Read tool_result as the output when tool_response is absent or null.

  • In the raw payload, replace tool_input and the output key the entry was built from with a marker, for example "tool_response": {"obot_sentry_omitted": "details.response.body"}. Every other field is kept as the agent sent it.

  • Only keys the parser actually read are replaced. Output in a field the parser does not know about stays in the raw payload, so a new payload shape still reaches the server (this is what preserved the VS Code output until now).
  • Compatibility

  • Older Obot servers accept the slimmer raw event: ingest only requires rawEvent to be non-empty JSON.

  • Idempotency keys are unchanged; they are still derived from the payload as the agent sent it.

  • Raw event key order is no longer preserved: top-level keys come out sorted, because the payload is rewritten as a JSON object.
  • Reviewer notes

  • For VS Code, the response body is the whole tool_result object rather than just text_result_for_llm. That keeps the extraction lossless, at the cost of the body being an object where the Local harness gives a string. Say if you'd prefer the text alone.

  • The audit log UI's "Raw Event" panel will show the markers for events from this version onward. Stripping the same duplicates at server ingest, for Sentry versions already deployed, is a separate change in obot-platform/obot.
  • Testing

  • go test ./... and go vet ./... pass. golangci-lint was not run locally.

  • New tests use the field sets observed in real hook payloads from Claude Code 2.1.322, Codex 0.167.2, Cursor CLI 2026.11.11 and Copilot CLI 1.0.109.

  • Replayed those captured payloads through audit submit --dry-run --print-normalized before and after: all six Copilot post-tool events now have a non-null response body, and the submitted size for an 11-event Claude Code session drops from about 140 KB to 84 KB.

  • Not tested against a running Obot server or inside VS Code itself; the Copilot-harness payload was captured from Copilot CLI.
  • Addresses obot-platform/obot#8420

    🤖 Generated with Claude Code

    Diff: 356 lines (+267 / -89) across 4 files Reviewer: claude[bot] Review duration: 5m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.48) × (1 − Review Confidence (0.38)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 356 lines diff across 4 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 64% · Reviewer familiarity: 35%
    37%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.352
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #48"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 37.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.5% (MEDIUM) · Higher = larger blast radius
    47.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 37.9% · Lower = rushed or shallow review
    37.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.5% · Safe to merge
    29.5%