Skip to content

Attribute subagent tool calls (agent_id): reasoning cursor isolation + queued core patch - #73

Merged
githubscum merged 1 commit into
mainfrom
agent-id-attribution
Oct 26, 2026
Merged

githubscum merged 1 commit into
mainfrom
agent-id-attribution

Conversation

@githubscum

Copy link
Copy Markdown
Owner

Why

Claude Code now fires PreToolUse and PostToolUse for tool calls made inside a subagent. Those payloads carry the parent's session_id and transcript_path, plus agent_id and agent_type. Lotor read neither field. Two live probes on 2026-10-22 showed what that does:

  1. Misattribution. A subagent's echo showed up as a parent reasoning step marked unrecorded: tool-use-not-in-transcript, because Lotor looked for it in the parent's transcript.
  2. Cursor corruption. The same child call advanced the parent's reasoning cursor through 9,495 bytes of the parent's transcript, since cursor files are keyed by session id only. A child call can claim or skip the parent's reasoning.

A second probe found that a subagent's read of the chain stops at the self-mod gate. KNOWN-LIMITS 66 and 70 ("subagent tool use is outside the witness entirely") were true when measured on 2026-09-02 and are out of date for the current harness. The amendments are drafted separately and land with the core patch.

What changes

Grantable, takes effect on merge (src/reasoning):

  • A child call uses its own cursor under reasoning/cursors/agents/<session>/<sha256(agent)>.json. A child call can no longer produce a parent cursor path, and loadCursor discards a cursor whose sidechain mode doesn't match.
  • The child's transcript is read from the documented agent_transcript_path when present, otherwise from the src/ingest/subagents.js convention, with sidechain lines included.
  • Child steps carry agentId/agentType and are excluded from the parent's reconcile.
  • An invalid agent_id is refused as agent-id-invalid, with no cursor touched and no path escape.
  • A parent call's step is byte-identical in shape to before.
  • test/reasoning-subagent.test.js: 12 tests.

Core, queued for the signing sitting, not applied here:

  • proposals/agent-id-attribution.patch (16 hunks across bin/hook-pre-tool-use.js, src/gate/index.js, bin/hook-post-tool-use.js):
    • gated-action, policy-warn and grant-use rows gain agentId/agentType only when present.
    • egress-event gains sessionId.
  • test/agent-id-attribution.test.js: 7 cases, todo until the patch lands.
  • Sitting steps: proposals/agent-id-attribution.md.

Evidence

  • glm-5.3-flash built it, through two work orders. A Claude Sonnet reviewer from a second model family checked it and found two patch-format blockers, which are fixed. All 16 hunks were recounted with 0 mismatches.
  • Test run in a fresh clone without npm ci: 1263 pass, 7 todo, 8 fail.
    • The 8 failures come from 7 files that need @modelcontextprotocol/sdk or qrcode.
    • The same 7 files fail on a clean c69f552 in that clone.
    • No failures come from this change.
  • Not verified here: git apply --check on the core patch. It touches protected paths, so it is the first signed step at the sitting.

Open decisions (not changed by this PR)

  • A subagent shares its parent's session_id, so a grant issued to the parent session also covers its subagents' calls.
  • Engine-error and unknown-mode policy-warn rows carry no agent fields.

🤖 Generated with Claude Code

…re patch

Claude Code fires PreToolUse/PostToolUse for tool calls made inside a
subagent, with the parent's session_id plus agent_id/agent_type. Lotor read
neither. Two live probes on 2026-10-22: a child's Bash call was recorded as
the parent's (unrecorded: tool-use-not-in-transcript), and it advanced the
parent's reasoning cursor through 9,495 bytes of the parent's transcript.

Grantable (src/reasoning): child calls use their own cursor (separate
directory, hashed agent id), read the child transcript with sidechain lines
included, carry agentId/agentType on the step, and are excluded from the
parent's reconcile. Invalid agent ids are refused as agent-id-invalid.

Core (queued for the signing sitting, not applied):
proposals/agent-id-attribution.patch adds agentId/agentType to gate,
policy-warn and grant-use rows only when present, and sessionId to
egress-event. test/agent-id-attribution.test.js is todo until it lands.

Built by glm-5.3-flash (WO-AGENT-ID, FIX1); second-family review by Claude
Sonnet; patch hunks recounted (16, 0 mismatches).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@githubscum
githubscum merged commit 52ca451 into main Oct 26, 2026
githubscum added a commit that referenced this pull request Oct 26, 2026
…e under signature

Applied in the live install, each step signed by the owner:
- precondition: live chain 42,567 entries, seq continuous (scan signed, 13668b04).
- chain: verifyChain checks seq continuity (proposals/verifychain-seq-continuity,
  #74), signed 008521ce.
- gate and hooks: subagent tool calls carry agentId/agentType on gate receipts
  (proposals/agent-id-attribution, #73), signed 74885c4c.
- policy: matcher/3 folds CRLF so one commit has one stamp
  (proposals/l77-matcherhash-eol, #82, KNOWN-LIMITS 77), signed 7f124e65.
- tests: agent-id describe todo marker removed; seq and l77 tests detect the
  landing on their own.

Found during the sitting: KNOWN-LIMITS 82. The first apply, `git apply <patch>`,
rewrote src/chain/index.js with no gate stop and no receipt, because the
matcher reads paths from argv and the patch carries them in its bytes. It was
reverted under signature (34b2dca0) and every patch was re-applied with its
targets named via --include, which the matcher sees.

Pin re-stamp follows in its own commit; mechanical, not a re-verification of
every limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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