Skip to content

fix(session): attribute MCP work to caller session - #1241

Open
agammann wants to merge 1 commit into
mksglu:nextfrom
agammann:fix/caller-session-attribution
Open

agammann wants to merge 1 commit into
mksglu:nextfrom
agammann:fix/caller-session-attribution

Conversation

@agammann

@agammann agammann commented Oct 2, 2026

Copy link
Copy Markdown

What / Why / How

Fixes #1198. When two Claude Code sessions share a project, MCP work can be attributed to the most recently started session instead of the caller.

Resolve the caller from the explicit CLAUDE_SESSION_ID override, then Claude Code's live sessions/<parent-pid>.json file, then the inherited CLAUDE_CODE_SESSION_ID. Keep the existing session DB fallback for other hosts. Apply this to indexed content, session events, persistent tool-call counts, restored stats, and the per-conversation ctx_stats lookup. Reading the live file on each call also handles /clear when the inherited ID is stale.

Affected platforms

  • Claude Code

Test plan

  • pnpm exec vitest run tests/session/caller-session.test.ts tests/session/event-emit.test.ts tests/session/server-tool-call-wiring.test.ts: 18 passed.
  • pnpm run typecheck: passed. Build and bundle assertions passed.
  • MCP stdio check with two seeded sessions: the built server inherited the neighbor's ID but read the caller's live session file; a ctx_execute tool-call row and sandbox event were both credited to the caller.
  • Full pnpm test on Windows: 4,687 passed, 41 failed, 77 skipped. The failures were in shell/Python, symlink-permission, /tmp, and npm pack tests; the targeted session suites passed.
  • Live Claude Code CLI session and transcript were not run because the CLI is unavailable in this environment.

Checklist

  • Tests added/updated
  • npm test passes
  • npm run typecheck passes
  • Docs updated if needed (internal attribution change; no docs updated)
  • No Windows path regressions (uses path.join())
  • Targets next branch (unless hotfix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant