Problem
Traces currently record prompt excerpts, line ranges, and files changed — but the intent (the why behind the change) is almost never populated. The intent field exists in AgentdiffMetadata and flows through the full pipeline, but it defaults to "unspecified" because there is no reliable acquisition path.
The prompt excerpt is used as a proxy, but prompts describe what to do, not why:
- "fix the auth bug" — was this a security incident? a test failure? a refactor?
- "do the thing we talked about" — completely opaque
- Multi-step sessions produce many tool calls under one vague prompt
This is the bottleneck for making PR comments and review context meaningful.
Approach
Have the agent state its own intent as a session.jsonl event right before it commits (or at session end). The agent has full context of what it did and why — instead of reverse-engineering intent from diffs/prompts, just ask it.
Mechanism: MCP tool call (Option A)
- Add a
set_intent MCP tool (or extend record_context) that writes an intent event directly to session.jsonl
- Agent rules (
.cursor/rules/, CLAUDE.md, etc.) instruct agents: "Before committing, call set_intent with a 1-2 sentence description of why you made these changes"
prepare-ledger.py reads the most recent type: "intent" event from session.jsonl for the matching session and uses it as the intent field
- Everything downstream (finalize, report, PR comments) works as-is
New session.jsonl event format
{
"timestamp": "2026-05-21T12:00:00Z",
"type": "intent",
"agent": "cursor",
"session_id": "conv-xyz",
"description": "Extract auth middleware into shared module to fix duplicate token validation across 3 route handlers"
}
Implementation Steps
- MCP tool: Add
set_intent tool to agentdiff-mcp.rs that writes intent events to session.jsonl
- prepare-ledger.py: Read
type: "intent" events from session.jsonl, use matching session's intent as the intent field in the payload
- Agent rules: Add default rules for Cursor and Claude Code that instruct agents to call
set_intent before committing
- Optional:
intent_type field: Add a taxonomy classifier (bugfix/feature/refactor/test/docs/security/config) derived from the diff, as a fallback when no agent-stated intent exists
- Report update: Show
intent_type + intent together in PR comment output
Why this works
- Zero latency — no external API calls
- Zero cost — no LLM inference
- High quality — the agent has full session context
- Fits existing architecture — session.jsonl → prepare-ledger → finalize → traces
- Works across all MCP-capable agents
Acceptance Criteria
Problem
Traces currently record prompt excerpts, line ranges, and files changed — but the intent (the why behind the change) is almost never populated. The
intentfield exists inAgentdiffMetadataand flows through the full pipeline, but it defaults to"unspecified"because there is no reliable acquisition path.The prompt excerpt is used as a proxy, but prompts describe what to do, not why:
This is the bottleneck for making PR comments and review context meaningful.
Approach
Have the agent state its own intent as a session.jsonl event right before it commits (or at session end). The agent has full context of what it did and why — instead of reverse-engineering intent from diffs/prompts, just ask it.
Mechanism: MCP tool call (Option A)
set_intentMCP tool (or extendrecord_context) that writes an intent event directly tosession.jsonl.cursor/rules/,CLAUDE.md, etc.) instruct agents: "Before committing, callset_intentwith a 1-2 sentence description of why you made these changes"prepare-ledger.pyreads the most recenttype: "intent"event from session.jsonl for the matching session and uses it as the intent fieldNew session.jsonl event format
{ "timestamp": "2026-05-21T12:00:00Z", "type": "intent", "agent": "cursor", "session_id": "conv-xyz", "description": "Extract auth middleware into shared module to fix duplicate token validation across 3 route handlers" }Implementation Steps
set_intenttool toagentdiff-mcp.rsthat writes intent events to session.jsonltype: "intent"events from session.jsonl, use matching session's intent as theintentfield in the payloadset_intentbefore committingintent_typefield: Add a taxonomy classifier (bugfix/feature/refactor/test/docs/security/config) derived from the diff, as a fallback when no agent-stated intent existsintent_type+intenttogether in PR comment outputWhy this works
Acceptance Criteria
set_intentMCP tool writes intent events to session.jsonlprepare-ledger.pypicks up intent events and populates the intent field