Repository navigation
fix: active-memory recall fails with billing rejections on subscription-only Claude CLI setups - #106840
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 16, 2026, 3:25 AM ET / 07:25 UTC. Summary PR surface: Source +876, Tests +1155, Docs +3. Total +2034 across 33 files. Reproducibility: yes. The linked issue gives a concrete current-main subscription-only Claude CLI setup whose active-memory helper reaches the direct API path and deterministically receives the billing rejection, and the PR supplies before/after live logs from the same class of setup. Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Keep the provider-owned dispatch capability fail-closed and opt-in, but land it only after the runtime owner accepts the permanent API shape, the branch is refreshed against current main, and exact-head checks confirm subscription dispatch, API-key passthrough, pinned-profile routing, bounded MCP tools, lifecycle parity, transcripts, abort handling, and conditional timeout behavior. Do we have a high-confidence way to reproduce the issue? Yes. The linked issue gives a concrete current-main subscription-only Claude CLI setup whose active-memory helper reaches the direct API path and deterministically receives the billing rejection, and the PR supplies before/after live logs from the same class of setup. Is this the best way to solve the issue? Unclear only at the permanent API boundary. The provider-owned, opt-in, fail-closed bridge is the narrowest technically coherent fix shown and preserves API-key behavior, but maintainers must decide whether this general plugin/runtime contract is preferable to folding the work into the broader helper-routing architecture. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7e1d93d36d76. Label changesLabel justifications:
Evidence reviewedPR surface: Source +876, Tests +1155, Docs +3. Total +2034 across 33 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (25 earlier review cycles; latest 8 shown)
|
869b614 to
2b7b5ba
Compare
2b7b5ba to
26e00b3
Compare
26e00b3 to
a03c794
Compare
a23f0cc to
3157bd8
Compare
565b1fb to
8add8c3
Compare
8add8c3 to
361e7af
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
07245c1 to
80e68ef
Compare
80e68ef to
cddf828
Compare
|
Requesting runtime-owner sign-off on the dispatch boundary — cc @steipete (ClawSweeper routed this decision to you as the likely runtime owner) This PR fixes a P1 for subscription-only Claude CLI users: active-memory recall fails on every eligible turn with Anthropic's billing rejection (or silently draws metered extra usage) because the embedded helper calls the API directly instead of going through the CLI. Details and full evidence are in the PR body; ClawSweeper's current verdict is "no concrete contributor-facing blocker" with proof rated sufficient. The one open item every review cycle has flagged is the permanent boundary question, and rather than wait I've implemented the option ClawSweeper recommended in each of its reviews — provider-owned capability:
The ask: approve this capability field as the seam (or tell me the shape you'd prefer — including folding into the broader helper-routing work in #57326 — and I'll rework; the dispatch/proof machinery is shape-neutral). For the three merge-risk labels, the proof shortcuts:
Branch is current with main and MERGEABLE; happy to do a final rebase at merge time. |
Patrick-Erichsen
left a comment
There was a problem hiding this comment.
Requesting changes for three contract regressions. The Active Memory named-tool path is bounded and the focused tests pass, but the new generic embedded-dispatch bridge does not preserve runEmbeddedAgent tool, auth, and lifecycle semantics.
cddf828 to
92917da
Compare
|
Thanks @Patrick-Erichsen — all three findings were correct, and all three are addressed on the current head ( 1. Tool-policy preservation → implemented as fail-closed. The dispatch gate now dispatches only when the embedded tool state is one the CLI bridge can express faithfully: a non-empty, wildcard-free named allowlist, translated to Why fail-closed rather than a full translation layer: refusal preserves the caller's assumed semantics exactly — no closed state can silently widen, and the wildcard-grant / merged-user-MCP-servers path you identified is now unreachable, because a run without a bounded grant never reaches prepare through this bridge. A faithful translation for the remaining states (deny-all, flag-based restrictions, true wildcard) would be machinery for callers that don't exist yet; today's only opted-in caller (active-memory) always passes a named allowlist. When the broader helper-path adoption tracked in #57326 brings a caller that needs one of those states, translating it then — with that caller's tests — seems like the right time to build it. Happy to do the full translation now instead if you'd prefer. 2. 3. Validation: full dispatch/eligibility/lane/prepare/active-memory suites green, tsgo clean, and a fresh live recall proof on the exact head ( |
0b09889 to
a58fbe0
Compare
…subscription-only claude-cli auth
Embedded runs targeting a CLI runtime provider fall through to the openclaw
harness and call the provider API directly with the runtime's credentials
(cli_runtime_passthrough_openclaw). Anthropic routes direct anthropic-messages
calls on subscription OAuth tokens to metered extra-usage billing — this is
long-standing behavior, not a recent change. Without extra-usage balance,
every such run (e.g. active-memory recall) fails with a billing error; with
extra-usage enabled, the run silently draws paid metered usage instead of the
plan limits the CLI runtime was configured for. Only CLI-backed execution
runs on plan limits for those credentials.
Add an opt-in RunEmbeddedAgentParams.cliBackendDispatch: "subscription-auth"
that dispatches the run through runCliAgent as a one-shot turn when the
provider is claude-cli, a CLI backend is registered, and the ordered auth
profile selection for the passthrough resolves to a subscription (oauth/token)
credential or nothing rather than an API key; resolution stays on stored
credential metadata, with no credential materialization or refresh on the
per-turn path. The dispatch translates toolsAllow into the selectable-backend
surface (native: [], allowlisted loopback MCP tools; wildcard allowlists stay
MCP-only), runs with a fresh CLI process (no live-session reuse; session-
scoped bundle-MCP retirement on run end rather than the process-wide loopback
close), bridges CLI tool result events to onAgentToolResult with native-path
semantics (normalizeToolName + isToolResultError), and drops CLI session
bindings from the result.
The selectable-backend MCP list now also bounds the loopback MCP grant
server-side: the grant carries a per-run gateway tool allowlist enforced in
scoped tool resolution, so tools outside the run's allowlist can be neither
listed nor called even under CLI bypass permission modes where
--allowedTools is advisory.
active-memory recall opts in so recall works on claude-cli subscription-only
instances and stops drawing metered extra usage where it previously could.
Scoped to claude-cli; other CLI runtimes keep the passthrough until their
direct-API contract is verified.
The dispatch also mirrors the run into the run's session transcript through the session
accessor (user turn, tool call/result records as they stream, final assistant
snapshot at run end) so transcript consumers keep parity with embedded runs:
active-memory's persistTranscripts, timeout partial-text salvage, and the
live terminal-search watcher that polls the session file mid-run.
Post-review hardening: canonical anthropic/<model> refs whose configured
agentRuntime is claude-cli resolve through the runtime policy before the
dispatch gate (they previously stayed on the failing passthrough); restricted
dispatches serve an exclusive loopback-only MCP bundle so user/plugin MCP
servers stay outside the run's tool universe; and the transcript recorder
flushes the latest assistant snapshot the moment the run aborts, so timeout
salvage sees partial text even while the killed CLI child is still settling.
Recalls routed to the claude-cli runtime default to a 45s budget (measured
CLI-dispatched runs take 14-20s, over the plain 15s default); explicit
timeoutMs config always wins.
Transcript mirror keeps bare-array tool_result content (claude stream-json
echoes MCP results without a {content} wrapper); dropping it classified every
successful recall as no_relevant_memory.
CLI dispatch resolves inside session/global lane admission so dispatched
runs obey the same lifecycle, placement, and concurrency gates as native
embedded runs.
LOC-ratchet offsets move the loopback grant-context builders to
cli-runner/mcp-grant-context.ts and dedupe the run/prep stage-summary
emitters into attempt-stage-timing.ts; unused type exports dropped and the
now-used stream-message baseline entry removed.
The recall timeout default now consumes the runner's own dispatch
eligibility through a new plugin-runtime seam
(agent.resolveCliBackendDispatchEligibility): API-key and missing-backend
routes keep the passthrough and its plain 15s default.
Eligibility honors an explicitly pinned authProfileId (the credential the
run executes on) before ordered profile selection, in both directions.
Transcript mirror composes buildAssistantMessage + buildUsageWithNoCost
directly; main trimmed the zero-usage wrapper export (ab0ccc2) before
this branch's usage landed.
Dispatch eligibility is provider-owned: the anthropic plugin's claude-cli
backend declares CliBackendPlugin.subscriptionAuthDispatch and core reads
the registered descriptor instead of a core provider allowlist.
Dispatch fails closed on tool policy (only non-empty named allowlists are
expressible on the CLI surface; deny-all, wildcards, absent allowlists, and
disableTools/modelRun keep the passthrough), threads the pinned
authProfileId into CLI runtime resolution, and emits onExecutionStarted at
the admitted dispatch boundary.
Closes #106839
Related: #86761
What Problem This Solves
Fixes an issue where agents running on the Claude CLI runtime with subscription-only auth (Claude Code OAuth, no Anthropic API key) would have every active-memory recall either fail with a billing rejection (no extra-usage balance) or silently draw paid metered extra usage (extra usage enabled) — while main-session turns correctly ran on plan limits through the CLI backend. Anthropic routing direct anthropic-messages calls on subscription tokens to extra-usage billing is long-standing behavior; the embedded runner's direct-API passthrough (
cli_runtime_passthrough_openclaw) was never a viable path for these credentials.Why This Change Was Made
Adds an opt-in
RunEmbeddedAgentParams.cliBackendDispatch: "subscription-auth": when the run's provider isclaude-cli— directly or via a canonicalanthropic/<model>ref whose configuredagentRuntimeis claude-cli — a backend is registered, and the ordered credential selection resolves to subscription (oauth/token) or nothing rather than an API key, the run executes throughrunCliAgentas a one-shot turn. Active-memory recall opts in. The dispatch preserves the embedded run's contracts:toolsAllowmaps to the selectable-backend surface, bounds the loopback MCP grant (tools outside it can be neither listed nor called, even under bypass permission modes), and restricted runs get an exclusive loopback-only MCP bundle — user/plugin MCP servers are not merged in.persistTranscripts, timeout partial-text salvage, and the live terminal-search watcher work identically to embedded runs.google-gemini-cliand custom backends keep the passthrough — their direct-API contracts were not verified and this PR makes no claims about them. An available API key keeps the existing fast passthrough. The core-side provider set could move to aCliBackendConfigcapability flag if maintainers prefer that seam.User Impact
Subscription-only Claude CLI deployments get working active-memory recall on plan limits, consistent with their main turns — instead of failing every turn or silently consuming paid extra usage. Setups with an Anthropic API key see no behavior change. No config changes required; note that CLI-dispatched recalls measured 13.8–16.9s on a dev laptop, so the plugin's default 15s
timeoutMsis tight — 30s is comfortable.Evidence
Current-head success (read this first): on PR head
aebb9ee1f7(a code-identical rebase of proof head92917da5ae, whose dist produced the run below), a live subscription-only recall with the default plugin config (notimeoutMsoverride) completes end-to-end:timeoutMs=45000is the new CLI-runtime default applied from unset config;status=okwith a grounded, cited summary is the successful default-config recall the review asked for. Details, the deny-path proof, and earlier rounds follow.Before (subscription-only claude-cli setup): every recall fails in under a second, with the recall session recording the direct
anthropic-messagesroute.Before: per-turn billing rejection on the passthrough
After (macOS, this branch, from source, no API key or synced credential profile): recall dispatches through the CLI backend as an independent one-shot process, the Claude child calls the memory tools through the grant-filtered loopback MCP bridge, and the run completes in 16.9s.
After: CLI-backend dispatch with grant-scoped MCP tool calls
After: persistTranscripts announcing the persisted transcript
After: the persisted OpenClaw transcript (full record chain)
{"type":"session","version":3,"id":"active-memory-mrjmuqgz-022c38a4","timestamp":"2026-07-13T19:46:16.431Z","cwd":"~/.openclaw/workspace-recall-probe2"} {"type":"message","id":"dfc7835d-0bd3-46a0-9993-243e8b34d2f3","parentId":null,"timestamp":"2026-07-13T19:46:16.431Z","message":{"role":"user","content":[{"type":"text","text":"You are a memory search agent.\nAnother model is preparing the final user-facing answer.\nYour job is to search memory and return only the most relevant memory context for that model.\nYou receive a bounded search query plus conversation context, including the user's latest message.\nUse only the available memory tools.\nUse the bounded search query with the configured memory tools.\nConfigured memory tools: memory_search, memory_get.\nDo not use channel metadata, provider metadata, debug output, or the full conversation context as the memory tool query.\nIf the available memory tools find nothing useful, reply with NONE.\nWhen searching for preference or habit recall, use permissive search limits or thresholds before deciding that no useful memory exists.\nDo not answer the user directly.\nPrompt style: balanced.\nTreat the latest user message as the primary query.\nUse recent conversation only to disambiguate what the latest user message means.\nDo not return memory just because it matched the broader recent topic; return memory only if it clearly helps with the latest user message itself.\nIf recent context and the latest user message point to different memory domains, prefer the domain that best matches the latest user message.\nIf the user is directly asking about favorites, preferences, habits, routines, or personal facts, treat that as a strong recall signal.\nQuestions like 'what is my favorite food', 'do you remember my flight preferences', or 'what do i usually get' should normally return memory when relevant results exist.\nIf the provided conversation context already contains recalled-memory summaries, debug output, or prior memory/tool traces, ignore that surfaced text unless the latest user message clearly requires re-checking it.\nReturn memory only when it would materially help the other model answer the user's latest message.\nMutable operational facts (cron/job health, automation status, deployments, incidents, service availability) go stale quickly: include the source timestamp when available, say when the memory may be stale, and tell the answering model to verify live before relying on it.\nDo not summarize mutable operational facts as simply current/running/healthy unless the memory result itself contains a current source timestamp and matching health state.\nIf the connection is weak, broad, or only vaguely related, reply with NONE.\nIf nothing clearly useful is found, reply with NONE.\nReturn exactly one of these two forms:\n1. NONE\n2. one compact plain-text summary\nIf something is useful, reply with one compact plain-text summary under 220 characters total.\nWrite the summary as a memory note about the user, not as a reply to the user.\nDo not explain your reasoning.\nDo not return bullets, numbering, labels, XML, JSON, or markdown list formatting.\nDo not prefix the summary with 'Memory:' or any other label.\n\nGood examples:\nUser message: What is my favorite food?\nReturn: User's favorite food is ramen; tacos also come up often.\nUser message: Do you remember my flight preferences?\nReturn: User prefers aisle seats and extra buffer over tight connections.\nRecent context: user was discussing flights and airport planning.\nLatest user message: I might see a movie while I wait for the flight.\nReturn: User's favorite movie snack is buttery popcorn with extra salt.\nUser message: Explain DNS over HTTPS.\nReturn: NONE\n\nBad examples:\nReturn: - Favorite food is ramen\nReturn: 1. Favorite food is ramen\nReturn: Memory: Favorite food is ramen\nReturn: {\"memory\":\"Favorite food is ramen\"}\nReturn: <memory>Favorite food is ramen</memory>\nReturn: Ramen seems to be your favorite food.\nReturn: You like aisle seats and extra buffer.\nReturn: I prefer aisle seats and extra buffer.\nRecent context: user was discussing flights and airport planning. Latest user message: I might see a movie while I wait for the flight. Return: User prefers aisle seats and extra buffer over tight connections.\n\nBounded memory search query:\nTranscript parity check: what are my favorite wings?\n\nConversation context:\nRecent conversation tail:\nuser: Quick memory check: favorite wings?\nuser: Final check: what are my favorite wings again?\nassistant: Lemon pepper. 🍋\n\nLatest user message:\nTranscript parity check: what are my favorite wings?"}],"timestamp":1783971976429}} {"type":"message","id":"321b2cf2-f121-447c-944d-11706bac311a","parentId":"dfc7835d-0bd3-46a0-9993-243e8b34d2f3","timestamp":"2026-07-13T19:46:27.465Z","message":{"role":"assistant","content":[{"type":"toolCall","id":"toolu_01XBmeEUymFqWkprAMaRZLun","name":"memory_search","arguments":{"query":"favorite wings"}}],"stopReason":"toolUse","api":"cli","provider":"claude-cli","model":"claude-opus-4-8","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"timestamp":1783971987464}} {"type":"message","id":"4b72573e-fcc8-4d18-ace2-2371104ccba7","parentId":"321b2cf2-f121-447c-944d-11706bac311a","timestamp":"2026-07-13T19:46:27.897Z","message":{"role":"toolResult","toolCallId":"toolu_01XBmeEUymFqWkprAMaRZLun","toolName":"memory_search","content":[],"isError":false,"timestamp":1783971987896}} {"type":"message","id":"73114aef-2ca5-4954-af62-95b5f8bcff37","parentId":"4b72573e-fcc8-4d18-ace2-2371104ccba7","timestamp":"2026-07-13T19:46:32.683Z","message":{"role":"assistant","content":[{"type":"toolCall","id":"toolu_01RwHa7h5UodUnbYFTC2AsQk","name":"memory_get","arguments":{"path":"favorite-wings.md"}}],"stopReason":"toolUse","api":"cli","provider":"claude-cli","model":"claude-opus-4-8","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"timestamp":1783971992682}} {"type":"message","id":"e01c5415-f452-41d4-ad26-662e9dd0942b","parentId":"73114aef-2ca5-4954-af62-95b5f8bcff37","timestamp":"2026-07-13T19:46:32.702Z","message":{"role":"toolResult","toolCallId":"toolu_01RwHa7h5UodUnbYFTC2AsQk","toolName":"memory_get","content":[{"type":"text","text":"{\n \"path\": \"favorite-wings.md\",\n \"text\": \"\",\n \"disabled\": true,\n \"error\": \"path required\"\n}"}],"isError":true,"timestamp":1783971992701}} {"type":"message","id":"bdb84eb0-04c4-43f2-8510-66f0684ad020","parentId":"e01c5415-f452-41d4-ad26-662e9dd0942b","timestamp":"2026-07-13T19:46:35.392Z","message":{"role":"assistant","content":[{"type":"text","text":"User's favorite wings are lemon pepper."}],"stopReason":"stop","api":"cli","provider":"claude-cli","model":"claude-opus-4-8","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"timestamp":1783971995391}}Round 3 (ClawSweeper review follow-up — successful default-config recall, deny-path proof, and a route-sensitive default budget):
[], wildcards, absent allowlists, anddisableTools/modelRunkeep the embedded passthrough, so no closed state widens and the wildcard-grant/merged-MCP-servers path is unreachable. (2) Eligibility forwards the pinnedauthProfileIdinto CLI runtime resolution, matching sibling routing callers. (3) Dispatched runs emitonExecutionStarted(withlifecycleGeneration) at the same post-admission boundary as the native path. Regression tests cover each closed-state refusal, the pin forwarding, and the lifecycle signal.CliBackendPlugin.subscriptionAuthDispatch: true(documented indocs/plugins/cli-backend-plugins.md), and core eligibility reads the registered backend descriptor: no descriptor or no declared capability → the passthrough is untouched. Backends that never declare it (gemini, codex, config-only backends without a plugin descriptor) are structurally excluded, replacing the hardcoded claude-cli set. This implements the "Adopt a generic backend capability (recommended)" option from the ClawSweeper maintainer-decision block; the remaining owner ask shrinks to approving the new SDK capability field.RunEmbeddedAgentParams.authProfileIdnow threads through the shared eligibility decision — a run pinned to an API-key profile keeps the passthrough (and the 15s default) even when the ordered selection would pick a subscription profile, and a pinned OAuth/token profile dispatches even when an API key sorts first; an unresolvable pinned id falls back to ordered selection like the passthrough. Profile-selection regression tests cover both explicit directions plus the fallback. Live proof of both routing directions on this head is in the lead block above (subscription → 45s dispatchstatus=ok; seeded claude-cli API-key store → 15s passthrough, no dispatch).cli-backend-dispatch-eligibility.ts, consumed by both the dispatch itself and a new plugin-runtime seamapi.runtime.agent.resolveCliBackendDispatchEligibility(documented indocs/plugins/sdk-runtime.md). Active-memory's 45s default now applies exactly when the run will dispatch through the CLI backend — API-key and missing-backend routes that keep the direct passthrough keep the plain 15s default. Regression tests: core eligibility (oauth resolves, API-key undefined, missing backend undefined, canonical-ref resolution) plus plugin-level budget tests for the eligible and ineligible paths.timeoutMsdefault. When the recall route resolves to theclaude-cliruntime (direct provider ref or a canonicalprovider/modelref whose configuredagentRuntime.idisclaude-cli), the default budget is now 45s. This changes one default surface only for routes that could not work before this PR; an explicitly configuredtimeoutMsalways wins, and no new config keys are added. Help text updated inopenclaw.plugin.json.timeoutMswas removed from the plugin config. The run below is the full success chain on a subscription-only claude-cli route: new default applied, CLI-backend dispatch, realmemory_searchhits, grounded cited summary,status=ok.no_relevant_memorywithsummaryChars=0despite the model returning the correct facts: claude stream-json echoes MCPtool_resultcontent as a bare content-block array, and the transcript mirror only unwrapped{content: [...]}shapes, so every mirrored tool result was empty and active-memory's usable-result gate discarded the summary. Fixed incli-backend-dispatch-transcript.tswith a regression test pinning the live stream shape. (This also explains the empty"content":[]tool results visible in the earlier transcript excerpt above.)main, the dist was rebuilt from PR head2b7b5bac7dand the same default-config run repeated:start timeoutMs=45000→ CLI-backend dispatch → two groundedmemory_searchhits →done status=ok elapsedMs=13661 summaryChars=109("User prefers SQLite with Kysely for prototypes; Copperfin demo project's staging dashboard runs on port 4173.").run.ts: the CLI-dispatch decision moved from the top ofrunEmbeddedAgentto inside the lane-admitted global-lane task, so dispatched runs now pass the same session/global lane queues, lifecycle-generation checks, harness admission, placement turn admission, and run-context claiming as native embedded runs. A new ordering test (run.cli-dispatch-lane.test.ts) pins that both lane admissions fully wrap dispatch resolution and execution. The live success run above executed on this shape.check-dependenciesalso required the dispatch internals (resolveEmbeddedCliBackendDispatch,runEmbeddedAgentViaCliBackend) to stop being test-only exports — knip's production scan does not count test imports. They are module-private now and the gate tests exercise the publicrunEmbeddedAgentViaCliBackendIfEligiblewrapper.check-dependenciesandchecks-fast-loc-ratchetCI checks are repaired: the three unused type exports are no longer exported and the now-usedbuildAssistantMessageWithZeroUsagebaseline entry is removed; the three grown legacy files were brought back under their ratchet baselines by moving the loopback grant-context builders into a newcli-runner/mcp-grant-context.tsmodule, deduplicating the run/prep stage-summary emitters intoattempt-stage-timing.ts(they were verbatim copies), and simplifying an ad-hoc type guard with the existingisRecordhelper. No behavior change; existing prepare/grant/lane tests cover the moved code.check-dependenciesfailure on currentmain. The two remaining knip findings on this PR's merge ref (attempt-abort.ts: releaseEmbeddedAttemptSessionLockForAbort,attempt-prompt-skip.ts: PromptSubmissionSkipReason) reproduce identically on a pristineupstream/maincheckout (4bff6b188e) with the exact CI knip invocation — they were introduced by recent main-side refactors and are unrelated to this branch. All findings for files this PR touches are resolved.bypassPermissions. While a recall run was live, the child's grant credentials (Bearer token + capture-key header, lifted from the child's process environment) were replayed from an independent MCP client:tools/listreturned only["memory_get","memory_search"], the allowedmemory_searchreturned real indexed content, and the excludedsessions_listwas rejected at the grant layer (isError:true, "Tool not available"). A token-only replay without the capture-key header was rejected401 unauthorized.After (round 3): default-config success run — status=ok with grounded summary
After (round 3): live deny-path replay against the loopback grant
Validation:
pnpm checkandpnpm buildclean.codex review --base upstream/mainrun locally; all seven findings across both rounds fixed in-branch with tests.src/agents/embedded-agent-runnersuite (1909 tests) green after the deadline default and bare-array fixes;tsgocore and test-type lanes clean; branch rebased onto currentmain.packages/speech-core/src/tts.test.ts). CI should be treated as the authoritative full gate.AI session log (curated: prompts + review rounds)
AI session log (curated)
This change was developed in a single interactive Claude Code (Claude Fable 5)
session, human-directed throughout. This is a curated log — author prompts
are quoted verbatim where they contain nothing private, and marked
[redacted: …]where they referenced the author's own infrastructure; agentwork is summarized. The raw transcript is withheld because it interleaves
private operator configuration; it can be shared with maintainers on request
after review.
1. Task briefing (author prompt, redacted paraphrase)
2. Investigation (agent, with parallel research subagents)
Mapped both dispatch paths (embedded runner vs
runCliAgent), confirmed noCLI dispatch existed for embedded runs, and ran three parallel deep-dives:
CLI live-session concurrency (distinct session ids run as independent
processes), the selectable-backend tool surface (
toolsAllowfails closed onCLI runs;
cliToolAvailabilityis the supported restriction), and credentialmode detection (claude-cli profiles are always subscription OAuth; mode is
resolvable from stored metadata without network).
3. Implementation and first review round
Implemented the opt-in
cliBackendDispatch: "subscription-auth"dispatch,then ran a multi-angle AI review (8 independent finder passes + verification)
which produced fixes: a cheap ordered-credential gate instead of credential
materialization on the per-turn path, native-path semantics for the bridged
tool results, wildcard-allowlist handling, and a shared MCP-prefix helper.
4. Author scope and framing direction (verbatim prompts)
5. Codex review rounds (per CONTRIBUTING)
codex review --base upstream/mainwas run locally twice. Round 1 (4findings): grant-level tool enforcement on the loopback MCP surface, ordered
auth-profile selection for mixed stores, session-scoped MCP cleanup instead
of the process-wide server close, and transcript persistence. The author
directed full transcript parity:
Round 2 (3 findings, after the parity work): exclusive loopback-only MCP
bundle for restricted runs, canonical
anthropic/<model>refs resolvingthrough the runtime policy before the dispatch gate, and abort-time flushing
of the streamed assistant snapshot. All seven findings across both rounds
were verified against source before fixing, fixed with tests, and re-validated.
6. Validation
Focused unit/integration suites for every touched surface;
pnpm checkandpnpm buildclean; end-to-end verification on macOS from source with ascratch profile and subscription-only auth (dispatch, grant-filtered MCP tool
calls, persisted transcript chain, 13.8–16.9s latency measurements). Local
full-suite runs were load-flaky; every failure was triaged as pass-on-idle or
pre-existing on clean upstream/main.
7. Author understanding
Scope, semantics, naming, and framing decisions were made by the human
author; the final diff, commit message, and this evidence set were reviewed
by the author before submission.
AI-assisted: developed with Claude Code (Claude Fable 5); reviewed and understood by the author; two local Codex review rounds applied pre-submission (findings and disposition in the session log above).
🤖 Generated with Claude Code