Skip to content

fix(agents): agent --local exits silently when the session key has uppercase letters - #196869

Open
scoootscooob wants to merge 3 commits into
mainfrom
fix/agent-local-mixed-case-session-key
Open

scoootscooob wants to merge 3 commits into
mainfrom
fix/agent-local-mixed-case-session-key

Conversation

@scoootscooob

@scoootscooob scoootscooob commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Problem

On main, openclaw agent --local --session-key <key> exits with code 13 and no output whenever the key contains an uppercase letter (for example a Slack channel id, agent:main:channel:C3TT2OEIAJ7). stderr shows only Node's Warning: Detected unsettled top-level await at openclaw.mjs. Lowercase keys work. 2026.11.2 and 2026.11.3 are not affected.

Repro on c581fe0 (any provider; fails before the first model request):

openclaw agent --local --session-key agent:main:X --message hi --json   # exit 13, empty stdout
openclaw agent --local --session-key agent:main:x --message hi --json   # ok

The Gateway is affected too: POST /v1/responses with an uppercase x-openclaw-session-key (for example agent:main:channel:C3TT2OEIAJ7) never returns on c581fe0; the Gateway log shows reply watchdog: ... action=warn reason=no_semantic_progress. The openclaw agent client through the Gateway is not affected.

Cause

agentCommandInternal claims the session turn with withSessionTurn under prepared.sessionKey, the key as given. The embedded runner then admits its own turn under the stored key (prepareEmbeddedRunSession replaces sessionKey with runSessionTarget.sessionKey, which is case-folded). withSessionTurn inherits the ambient owner only when owner.aliases.has(sessionKey), an exact match, so the runner does not inherit the command's claim. Its target still resolves to the same mailbox through the session-id alias, so it submits a second task behind the claim its own caller holds. Session-controller diagnostics show it:

source-claim selected  pendingInputs=1 reason=claim-owned      (command)
lifecycle-admission settled reason=acquired
source-claim waiting   pendingInputs=2 reason=claim-owned      (runner, never selected)

Nothing else keeps the event loop alive, so the process exits.

Loosening the alias match is not enough: with that change alone the run fails later with "Native registration does not match the exact admitted session turn", so exact-key identity is relied on downstream.

Fix

Claim the command's turn under the stored key (normalizeStoreSessionKey), the same key the runner uses, so both layers name the same owner.

Verification

  • New test in agent-command.cancellation.test.ts: times out without the change, passes with it.

  • agent-command.cancellation, agent-command.admission-failure, agent-command-local suites: 36 passed.

  • End to end on a build of c581fe0 with the equivalent change applied to the bundle: 40 multi-turn trials launched with agent --local and mixed-case keys, 0 failed turns of 110 (56 of 110 failed before), and a second turn on the same key sees the first turn's history.

  • Gateway /v1/responses with mixed-case session keys, same patched build: 40 multi-turn trials, 0 failed turns (the unpatched build hangs on the first such turn).

Not run locally: the full test suite and the type check. The test adds 18 lines; I can add a config/test-lines-allocations entry if you want it kept as a separate test.

🤖 Generated with Claude Code

…percase letters

The agent command claims the session turn under the key it was given, while the
embedded runner admits its turn under the stored (case-folded) key. Session
controller admission matches the owner by exact key, so the runner did not
inherit the command's claim and queued behind it. Nothing else kept the event
loop alive, so Node exited with code 13 and no output.

Claim the turn under the stored key so both layers name the same owner.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Nov 10, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 6deef20dc6db0758eba7d0342a13adc61ce314e1, but the PR head is now b1e5257fdfac7795c8c56559f97549c7ed127c74. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-10T21:37:19.039Z sha 6deef20 :: needs changes before merge. :: [P3] Account for the regression’s added test lines

@clawsweeper clawsweeper Bot removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 11, 2026
Keeps both the mixed-case session key test and main's new ingress
admission tests in agent-command.cancellation.test.ts.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

This branch has not been deployed

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

Labels

agents Agent runtime and tooling P1 High-priority user-facing bug, regression, or broken workflow. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant