CedarCopilot wants to merge 3 commits into staging from feat/delegate-token-attribution
Live on prod, no production signal yet
Strict CloudWatch fallback found 2 prod failure log lines for [run-chat-agent-sdk] query() failed (Claude Code process aborted by user) in the last 24h while checking buildsubagentdefinitions, runchatviaagentsdk, _delegatetoken, agent-bound-chat.test, delegate-tokens.test.
Strict CloudWatch fallback found 2 prod failure log lines for [run-chat-agent-sdk] query() failed (Claude Code process aborted by user) in the last 24h while checking buildcedarsdkmcpserver, _delegatetoken, agent-bound-chat.test, delegate-tokens.test, delegate-tool-scoping.test.
Verification reached its budget before a verdict.
Verification reached its 120s wall-clock budget before a tied verdict. Libra is keeping this intent verifying until the next check.
Libra has verdicts on 0 of 7 tracked behaviors on prod; 7 are still being checked. Libra has 2 low-confidence degraded verdicts it is still confirming. Libra checks hourly for 3 days after each deploy.
delegate-tool-scoping.ts's scopeNamedDelegatesToOwnServers (introduced 5825c46e0,
2026-09-06 , a real, necessary fix for silently-broken field-ownership attribution on the
chat harness, PR #2699) gave every Task-delegatable named subagent its own dedicated MCP
server, each registering the full 23-tool family-tool schema set from scratch. On an
account with N subagents, that's N complete copies of ~25 tool schemas configured for the
SDK to connect to at session start , which is what caused real "Prompt is too long" /
context-overflow incidents on accounts with many subagents (Sherlock, 2026-09-08). A
same-day fix (a502820d7) addressed a different contributor (full subagent instruction
bodies inlined into prompt) but never touched this one, which is why the failure kept
recurring on the one real account with enough subagents (12) to hit it.
Identity now travels via a per-turn unforgeable token, not via which server a call arrives on:
delegate-tokens.ts (new): mints one random token per named delegate (mintDelegateTokens)
and the exact instruction line spliced into that delegate's own prompt
(delegateTokenPromptLine). Full trust-model writeup in the file header , unforgeable
(never appears anywhere two delegates can both see it), fail-safe (an unresolved token
degrades to today's un-attributed identity, never an elevated one).subagents.ts: mints tokens after agentIdsByName is known, splices each delegate's own
token into ONLY that delegate's own prompt. Delegates no longer get tools/mcpServers
overrides at all , they inherit the parent's one shared server, same as general-purpose
always did.mcp-server.ts: buildCedarSdkMcpServer takes a resolveDelegateAgentId resolver instead
of a fixed agentIdOverride + serverName. Every family tool's shape gains an optional
_delegateToken field (one line, not touched in any of the 23 individual tool files); a new
resolveCallAgentId helper strips it from the call's args and resolves it to a real
agentId, computed fresh per call instead of baked into the server at construction time.run-chat-agent-sdk.ts: builds exactly ONE Cedar server per turn (moved after
agentIdByToken is known), wired with the resolver.delegate-tool-scoping.ts: the per-agent-server multiplication is gone ,
scopeNamedDelegatesToOwnServers/perAgentServers deleted. What's left
(buildScopedMcpServers, findReservedCedarServerNameCollisions,
cedarToolNamesForServer) simplifies to match: one server, one reserved name.legacy-tool-name-map.ts: simplified the frontend tool-name-stripping regex , it used to
handle both the shared server and a per-delegate-shaped name; only the former exists now.No changes needed to the actual gated tools (updateConversationFieldsTool.ts,
writeDocumentTool.ts, task tools) , they already just read context.requestContext.get('agentId');
the fix is entirely upstream of them.
Ran a structural/security review against this diff before opening. Two real findings, both fixed in the second commit:
!) I'd introduced in the new isolation test, per
this repo's no-cast policy.Libra has not measured any production surfaces for this change yet.