Repository navigation
fix(auto-reply): stop minting channel source-turn ids for internal-origin turns - #109201
Merged
Merged
Conversation
…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.
Contributor
Author
|
Merged via squash.
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Every gateway
chat.sendturn carryingoriginatingChannel/originatingTooverrides dies withError: channel restart recovery requires source-keyed user-turn admissionon 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 gatewayclientRunIdas 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:shouldMintChannelSourceTurnIdskips 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-lesspersistUserTurnOnlybranch — 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.waitresult 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
verifyCodexChatImageProbefailed 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).webchat→ false), external (telegram) and undefined ingress unchanged.