Commit 5ff0a9e
committed
fix(cursor): unify conversation_id session-key precedence across all hook events
Surfaced by Cursor agent spec-check on PR #129 (2026-05-10). Previous
behaviour was: pre/postToolUse mapped by conversation_id, sessionEnd
preferred session_id with conversation_id fallback. Cursor's
sessionEnd payload contains BOTH (conversation_id from common-base
fields + session_id from event-specific fields), and the two IDs
identify different scopes (conversation_id = chat thread; session_id
= broader SDK session that may span multiple conversations).
The mismatch would orphan AXME sessions: pre/postToolUse creates
.axme-code/active-sessions/<conversation_id>.txt, then sessionEnd
looks up by session_id and finds nothing — clearClaudeSessionMapping
no-ops, the original mapping leaks, and the audit worker doesn't
fire on the right session.
Fix: always prefer conversation_id (present in every Cursor hook
payload via common-base fields), fall back to session_id only if
conversation_id is somehow absent. Apply to all three hook kinds
uniformly.
Tests updated: existing "uses session_id for sessionEnd" assertion
inverted to "uses conversation_id for sessionEnd"; new test for
session_id fallback when conversation_id absent.
Full suite: 573 / 573 (was 572 before fix; +1 new fallback test).
tsc clean. build clean.
Also supersedes memory cursor-sdk-system-prompt-via-inline-agent-...
(deleted) with cursor-sdk-system-prompt-prepend-to-first-send-...
after the same spec-check found that Agent.create() has no top-level
systemPrompt option and the agents+agentId pattern injects subagents,
not the outer agent's system prompt. PR-2 implementation will use
agent.send(`<system>\n\${SYSTEM}\n</system>\n\n\${user}`) instead.
This fix touches PR-1 code only; the PR-2 SDK adapter design is
already updated in the plan file.
#!axme pr=129 repo=AxmeAI/axme-code1 parent 6ee387f commit 5ff0a9e
2 files changed
Lines changed: 28 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
61 | | - | |
| 67 | + | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
65 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
66 | 80 | | |
67 | 81 | | |
68 | 82 | | |
| |||
0 commit comments