Skip to content

fix(auto-reply): stop minting channel source-turn ids for internal-origin turns - #109201

Merged
steipete merged 1 commit into
mainfrom
claude/chat-send-admission
Jul 16, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/chat-send-admission

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Every gateway chat.send turn carrying originatingChannel/originatingTo overrides dies with Error: channel restart recovery requires source-keyed user-turn admission on current main. Reproduced live twice on a Blacksmith Testbox (codex harness chat-image probe, real OpenAI key); text-only turns fail identically. Affected surfaces: qa-lab suite runtime dispatch, ACP-bridge flows (gateway-acp-bind / gateway-codex-bind), and any relay integration using admin-scope chat.send with originating-route fields. Real channel ingress (Telegram/Discord/…) and plain webchat/Control-UI chat.send are unaffected.

Why This Change Was Made

Regression from PR #108283: it started minting a durable channel source-turn id (channel-user:v1:<sha256>) for these turns by hashing the gateway clientRunId as if it were a provider message id, while the gateway's pre-created user-turn recorder still keys the persisted turn by run id (idem-<run>:user). The same PR's admission guard (restart-recovery-claim.ts) then throws on exactly that mismatch. CI missed it because the existing chat.send+originating tests mock dispatch and never drive real admission.

The semantic bug is identity conflation: channel source-turn ids exist to deduplicate provider redelivery after restart, and gateway-owned turns have no provider message — they already own restart via fingerprint-based admission (chat-restart-recovery.ts) plus client-side idempotent retries. Fix at the owning seam: shouldMintChannelSourceTurnId skips the mint when the actual ingress provider is the internal message channel, applied at both derivation sites (dispatch-from-config.ts, get-reply-run.ts). Admission then takes the existing source-less persistUserTurnOnly branch — pre-#108283 behavior for internal turns — while real channel ingress keeps the new source-keyed recovery unchanged. The rejected alternative (rekeying the gateway recorder by the minted hash) would grant gateway turns channel-style restart replay on top of client retries — double ownership with no shipped demand.

Also surfaces the full agent.wait result in the codex harness live test's error message (this is how the regression was diagnosed).

User Impact

Admin-scope chat.send with originating-route fields works again: qa-lab scenario dispatch, ACP bridge sessions, and relay integrations complete turns instead of erroring at admission. Channel restart recovery for real provider ingress is untouched.

Evidence

  • Live before/after on a Blacksmith Testbox with a real OpenAI key against the codex app-server harness: verifyCodexChatImageProbe failed twice on main with the admission error; with this fix the same run is admitted and executes (turn completes; the probe's remaining OCR assertion is a separate pre-existing media-path question, tracked separately).
  • New unit regression: internal ingress never mints (webchat → false), external (telegram) and undefined ingress unchanged.
  • Focused suites green: source-turn-id (5), agent-runner.runreplyagent e2e (23), dispatch-from-config pending-final, agent-runner-utils (111).
  • Autoreview (gpt-5.6-sol, xhigh): clean.

…igin turns

PR #108283 started deriving a durable channel source-turn id for gateway
chat.send turns carrying originatingChannel/originatingTo overrides, while
the gateway's pre-created user-turn recorder keys the persisted turn by run
id. The same PR's admission guard then throws 'channel restart recovery
requires source-keyed user-turn admission' for every such turn — breaking
qa-lab suite runs, ACP-bridge flows, and relay integrations (reproduced
live on the codex harness chat-image probe; text-only fails identically).

Internal-origin turns (gateway chat.send stamps the internal channel as the
ingress provider) carry run ids, not provider message ids; gateway turns
already own restart via fingerprint admission and client-side idempotent
retries. Skip the mint for internal ingress at both derivation sites so
admission takes the source-less persist path, while real channel ingress
keeps the new source-keyed recovery. Also surface the full agent.wait
result in the codex harness live test error (how this was found).

Live proof: gateway-codex-harness.live.test.ts chat-image probe on a
Blacksmith Testbox with a real OpenAI key failed with the admission error
twice on main and passes admission with this fix.
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Jul 16, 2026
@steipete
steipete merged commit 7e410bd into main Jul 16, 2026
139 of 142 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the claude/chat-send-admission branch July 16, 2026 16:48
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…igin turns (openclaw#109201)

PR openclaw#108283 started deriving a durable channel source-turn id for gateway
chat.send turns carrying originatingChannel/originatingTo overrides, while
the gateway's pre-created user-turn recorder keys the persisted turn by run
id. The same PR's admission guard then throws 'channel restart recovery
requires source-keyed user-turn admission' for every such turn — breaking
qa-lab suite runs, ACP-bridge flows, and relay integrations (reproduced
live on the codex harness chat-image probe; text-only fails identically).

Internal-origin turns (gateway chat.send stamps the internal channel as the
ingress provider) carry run ids, not provider message ids; gateway turns
already own restart via fingerprint admission and client-side idempotent
retries. Skip the mint for internal ingress at both derivation sites so
admission takes the source-less persist path, while real channel ingress
keeps the new source-keyed recovery. Also surface the full agent.wait
result in the codex harness live test error (how this was found).

Live proof: gateway-codex-harness.live.test.ts chat-image probe on a
Blacksmith Testbox with a real OpenAI key failed with the admission error
twice on main and passes admission with this fix.
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…igin turns (openclaw#109201)

PR openclaw#108283 started deriving a durable channel source-turn id for gateway
chat.send turns carrying originatingChannel/originatingTo overrides, while
the gateway's pre-created user-turn recorder keys the persisted turn by run
id. The same PR's admission guard then throws 'channel restart recovery
requires source-keyed user-turn admission' for every such turn — breaking
qa-lab suite runs, ACP-bridge flows, and relay integrations (reproduced
live on the codex harness chat-image probe; text-only fails identically).

Internal-origin turns (gateway chat.send stamps the internal channel as the
ingress provider) carry run ids, not provider message ids; gateway turns
already own restart via fingerprint admission and client-side idempotent
retries. Skip the mint for internal ingress at both derivation sites so
admission takes the source-less persist path, while real channel ingress
keeps the new source-keyed recovery. Also surface the full agent.wait
result in the codex harness live test error (how this was found).

Live proof: gateway-codex-harness.live.test.ts chat-image probe on a
Blacksmith Testbox with a real OpenAI key failed with the admission error
twice on main and passes admission with this fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant