Skip to content

codex app-server: turn interrupted after client-delegated message tool result (terminate:true) — promised work never executes #109490

Closed as not planned

Description

@antonsbot

Since 2026.7.1, client-delegated dynamic tools return terminate: true (tool-split runner). The Telegram/channel message tool is delegated, so when an agent sends a progress message ("I'll do X now") and then intends to continue working, releaseTurnAfterTerminalDynamicTool fires interruptCodexTurn and kills the rest of the turn.

Observed: 33 premature turn releases in one day on a gpt-5.5 codex app-server agent — trajectory events turn.dynamic_tool_terminal_release, all with tool: "message". Before 2026.7.1 the same setup logged ~0 such events per day. User-visible symptom: the agent "promises but never follows through" — any turn that sends a channel message before doing tool work gets interrupted right after the send.

Expected: a message-tool result should not be treated as the turn's terminal answer while the model has not completed its turn — or at least make this release behavior configurable per tool.

Repro sketch:

  1. Embedded codex app-server agent (openai/gpt-5.5) bound to a Telegram channel.
  2. Prompt it to first send a short progress message, then run any other tool (e.g. exec).
  3. On 2026.7.1 the turn is interrupted right after the message send (codex app-server turn released after terminal dynamic tool result in gateway log); the second tool never runs.

Local workaround: patch shouldReleaseTurnAfterTerminalDynamicTool to return false — restores pre-2026.7.1 behavior (model ends its own turn; idle timeouts still protect against hangs).

🤖 Generated with Claude Code

Activity

  1. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on Jul 17, 2026
  2. clawsweeper commented on Jul 17, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

    Close as a duplicate of the newer open report that tracks the same remaining omitted-final turn-termination behavior. Current main still intentionally terminates that path, so this is not an implemented-on-main closure.

    Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

    Root-cause cluster
    Relationship: duplicate
    Canonical: #127139
    Summary: The supplied open report names the same omitted-final Codex message behavior that current main explicitly implements.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Canonical path: Consolidate the omitted-finality contract and a native-tool-in-flight regression at #127139, with the Codex protocol source checked before changing the plugin lifecycle.

    So I’m closing this here and keeping the remaining discussion on #127139.

    Review details

    Best possible solution:

    Consolidate the omitted-finality contract and a native-tool-in-flight regression at #127139, with the Codex protocol source checked before changing the plugin lifecycle.

    Do we have a high-confidence way to reproduce the issue?

    Yes, at source level: in message_tool_only mode, send a confirmed message reply without final:false; current code makes it terminal and schedules turn/interrupt, though the authoritative Codex protocol source was unavailable here.

    Is this the best way to solve the issue?

    No for a separate fix: the newer open canonical report already owns the same omitted-finality contract; its repair should add an end-to-end boundary case for a progress reply followed by native work.

    Security review:

    Security review: This is an issue review without a proposed patch.

    AGENTS.md: found and applied where relevant.

    What I checked:

    Likely related people:

    • synth: Current source-reply finality and terminal-response lines blame to the recent outbound-message refactor. (role: recent area contributor; confidence: high; commits: 5e1a28bb5664; files: extensions/codex/src/app-server/dynamic-tools.ts, extensions/codex/src/app-server/dynamic-tools.test.ts)
    • Josh Avant: Authored the earlier merged progress-reply implementation referenced by the discussion; its commit is not in current main. (role: previous source-reply finality contributor; confidence: medium; commits: 8e6f966482b0; files: extensions/codex/src/app-server/dynamic-tools.ts)

    Codex review notes: model internal, reasoning high; reviewed against 13f0e02de62d.

  3. amr2393 commented on Jul 17, 2026

    @amr2393

    Stable-channel live repro (not just source-level) plus a variant that I think raises the severity: the release doesn't only skip promised work — it kills work that is already running in parallel.

    Environment: OpenClaw 2026.7.1 (2d2ddc4), embedded codex app-server, model openai/gpt-5.6-sol, Telegram group-topic session. Before 2026.7.1 this box logged zero turn.dynamic_tool_terminal_release events; they appear immediately after the update.

    Variant A — in-flight sibling call killed (live transcript, 2026-07-17 16:06Z)

    User message: run sh -c 'sleep 40; echo PROBE' backgrounded with yieldMs 1000, just ack

    The model emitted parallel calls in one response:

    1. native codex bash — sh -c 'sleep 40; echo PROBE' (16:06:34.459Z)
    2. dynamic message(action=send) — "ACK" (16:06:34.461Z)

    The message result returned ok (messageId delivered, 16:06:34.462Z) and the turn was interrupted ~2ms later — while the native bash was mid-sleep. The command never completed, no output was ever produced anywhere, and the session recorded a clean success. Trajectory shows turn.dynamic_tool_terminal_release with tool: "message".

    Implication for the fix: an in-flight native tool call evidently does not count toward the release guard's in-flight counters, so releaseTurnAfterTerminalDynamicTool fires even when the turn demonstrably has outstanding work. This is worse than message-loss — it is silent work-loss on a live user request.

    Variant B — classic ack-then-work truncation (2026-07-16, first post-update callback cycle)

    Two consecutive turns on a Telegram topic died immediately after a message ack ("I'll write it now" → silence); the user prodded twice and the deliverable arrived 36 minutes late. The third turn survived because it happened to run non-terminal dynamic tools (memory_search/web_fetch) before messaging — consistent with the currentTurnHadNonTerminalDynamicToolResult suppression path.

    Adjacent observation worth considering in the fix design

    After we deployed a prompt-level rule banning message-tool sends while work is pending, the model complied by acking via final streamed text instead — with the same native bash still in flight. The turn then completed on the final text and the in-flight call was orphaned anyway (OpenClaw wrote its "recorded a native Codex tool.call without a matching tool.result before the turn completed" reconciliation marker; no release event involved). So a fix scoped only to the message-tool release path still leaves early-turn-end orphan semantics for running native calls; treating "outstanding native tool call" as turn-not-terminal would cover both.

    Verified workarounds (live-tested, for anyone else hitting this)

    • Message send strictly last: when the send is the turn's final act, the release fires with nothing left to kill (we observed the event post-send in a passing run — harmless).
    • Prompt rule that actually holds: "do not end the turn — no final text and no message send — while any started tool call is running"; the message-tool-only version of the rule gets dodged via final text.
    • Mid-turn progress notes via the openclaw message send CLI in bash (native call, no dynamic-tool semantics) — unaffected.
    • Real backgrounding on this harness requires launchctl submit (macOS); nohup ... & children did not survive the app-server bash sandbox in two attempts.

    Full transcript/trajectory excerpts for all three runs available on request.

  4. EdgeClaws commented on Jul 17, 2026

    @EdgeClaws

    This looks already fixed on main by #108487 ("fix(codex): continue turns after progress replies", merged 2026-07-15), which makes omitted source-reply finality pending until the authoritative Codex turn/completed (explicit final:true stays terminal, final:false stays progress).

    Worth flagging for other reporters: #108487 merged after the v2026.7.1 release (published 2026-07-13), so anyone on shipped 2026.7.1 still reproduces this until the next release — but it should be resolved on main. Likely a dup of #106961 (which #108487 closed).

    For confirmation, we independently reproduced on shipped 2026.7.1 (2d2ddc4), embedded Codex app-server, openai/gpt-5.6-sol, including in a brand-new empty chat (so it's not context/compaction related): the first message(action=send) progress line releases the turn (codex app-server turn released after terminal dynamic tool result) and the follow-up work never runs.

  5. clawSean commented on Jul 17, 2026

    @clawSean
    Contributor

    Fix provenance + earliest testable release, to close out the review's "confirm the exact current-main fix commit" ask:

    Residual grit #108487 does not address (possibly worth its own issue): when a release legitimately happens (explicit final: true, or tool-owned terminate), it is still enforced via interruptCodexTurnBestEffort → app-server turn/interrupt (extensions/codex/src/app-server/run-attempt-lifecycle-controller.ts), so Codex records <turn_aborted> and injects "The user interrupted the previous turn on purpose." into thread history even for a clean, successful proactive close — misleading context for subsequent turns. #99442 (open) fixes abort detection on structural markers; the release-side semantics remain unclaimed. @amr2393's Variant A (in-flight sibling call killed ~2ms after the message result) also appears still reachable on the explicit-final path, since the release predicate's idle check can race freshly-batched native calls (per @thoughtmerchant's batching analysis on #107464).

  6. Johannes-Berggren commented on Jul 18, 2026

    @Johannes-Berggren

    Independent stable-channel confirmation on Slack (prior repros here were Telegram — this is channel-agnostic), OpenClaw 2026.7.1 (2d2ddc4), embedded codex app-server, openai/gpt-5.5.

    Clean A/B via config: with messages.visibleReplies (+ messages.groupChat.visibleReplies) at automatic we logged 0 turn.dynamic_tool_terminal_release events/day; the day we flipped both to message_tool we got 20 (all tool: "message"), and every affected turn shows the reported symptom: agent sends a progress note ("checking domain availability now"), release fires ~1ms after the send result, remaining work never runs.

    It's fully deterministic — a user follow-up ("status?") produced a second turn that acknowledged the interruption ("I got interrupted right after the first note"), sent that acknowledgment via the message tool, and was killed the same way.

    Config-only workaround for stable users (no dist patch): set messages.visibleReplies and messages.groupChat.visibleReplies back to automatic and restart the gateway (messages.* does not hot-apply on 2026.7.1). This removes message_tool_only source-reply delivery mode, so isDeliveredMessageToolOnlySourceReplyResult no longer marks implicit-route sends terminal — at the cost of the known unthreaded-reply behavior that message_tool mode was solving. Can confirm @clawSean's tag-containment finding: neither fix commit is on v2026.7.1, so config revert or explicit final:false prompting are the only stable-channel mitigations.

  7. dzisu commented on Jul 18, 2026

    @dzisu

    Additional live confirmation from a Telegram direct-chat OpenClaw instance, with a root-cause trace matching this issue.

    Environment

    • OpenClaw: 2026.7.1 (2d2ddc4)
    • Node: v24.18.0
    • Channel: Telegram direct chat
    • Source reply delivery mode observed in the affected path: message_tool_only
    • Reproduced/diagnosed locally: 2026-07-17 and 2026-07-18

    Observed behavior

    When the Codex agent sends an intermediate visible progress update via:

    message(action=send, "Checking ...")
    

    the turn is released immediately. Any subsequent native/tool work that the agent intended to run in the same turn is discarded. From the user perspective, the agent says it is starting work, then never follows through.

    Local log counts, privacy-scrubbed:

    /tmp/openclaw/openclaw-2026-07-17.log: 41 matching terminal-release/message-tool events
    /tmp/openclaw/openclaw-2026-07-18.log: 18 matching terminal-release/message-tool events
    

    The repeated pattern is:

    message(action=send) succeeds
    codex app-server turn released after terminal dynamic tool result
    turn.dynamic_tool_terminal_release
    

    No Telegram transport failure was observed; the failure boundary is after the successful message-tool result, at Codex turn release.

    Root-cause chain from local diagnosis

    1. message(action=send) is treated as a dynamic tool by the Codex integration.
    2. When it completes, the Gateway emits a tool.execution.completed diagnostic event.
    3. Because the message-tool response does not override diagnosticTerminalType, emitDynamicToolTerminalDiagnostic() defaults successful responses to terminal "completed".
    4. shouldReleaseTurnAfterTerminalDynamicTool() evaluates true once the app-server side appears idle.
    5. interruptCodexTurnBestEffort() interrupts the active Codex turn.
    6. Planned follow-up calls, for example native shell checks, never execute.

    The relevant local bundled code paths are equivalent to:

    • extensions/codex/src/app-server/run-attempt.ts: release after terminal dynamic-tool result, then interruptCodexTurnBestEffort(...)
    • extensions/codex/src/app-server/dynamic-tools.ts: emitDynamicToolTerminalDiagnostic(...) maps successful responses without an override to tool.execution.completed

    Expected behavior

    A visible mid-turn progress update should not terminate the Codex app-server turn. Termination should happen only when the message is explicitly the final source reply, or after the authoritative Codex turn completion.

    Workaround verified locally

    Operational workaround: do not use message(action=send) as an early progress indicator. Run the diagnostic/tool work first, then send one final visible response.

    This aligns with the suspected fix shape discussed above: preserve terminal release for final source replies, but classify progress/intermediate message sends as non-terminal, for example through explicit final: false / pending finality semantics.

    Authorship disclosure: this evidence was collected and privacy-scrubbed by the affected user's local OpenClaw agent at the user's request.

  8. Countermarch commented on Jul 18, 2026

    @Countermarch
    Contributor

    Additional stable-channel evidence for the same message-tool terminal-release family, from installed OpenClaw 2026.7.1 (2d2ddc4) on Telegram direct chat.

    What is additive here is the trajectory/audit classification: the affected main direct turns repeatedly ended as successful, status-only runs with no substantive work tools and no durable continuation, while nearby :active-memory: helper cancellations were separate sub-runs rather than the main direct run being cancelled.

    Observed pattern on 2026-07-18:

    • 10 strong incidents in one Telegram direct session between 11:31Z and 13:52Z.
    • Each affected ingress event completed and the main direct run ended success.
    • Each affected run sent only a visible message(action=send) progress/status/acknowledgement message, then stopped.
    • No bash/session/web/native tool work ran in those affected main turns, and no durable continuation/yield was created.
    • Nearby cancellations found in the same window were :active-memory: helper sub-runs, not the main direct Telegram run.
    • The same direct lane had known-good control turns in the same period that ran real tools and delivered final messages, so this was not a total Telegram ingress, gateway, app-server, or tool-execution outage.
    • Gateway health/stability and Telegram delivery were otherwise healthy; direct ingress rows had no failure reason.

    The strongest local hypothesis matches this issue: direct Telegram prompts require message(action=send) for visible output, and the installed terminal classifier treats committed message-tool delivery as explicit terminal success. When the model sends progress text like "checking now" as the only delivered message and then stops, the runtime records success even though the promised work never happened.

    Redaction note: local chat IDs, message bodies, account names, media details, private paths, and local numeric event IDs are omitted here. Preserved details are limited to version, UTC time window, channel, tool-count/status pattern, the main-run-vs-helper-cancellation distinction, and the known-good controls.

    No local runtime, prompt, config, gateway, session-store, or Telegram mutation was applied.

  9. Countermarch commented on Jul 18, 2026

    @Countermarch
    Contributor

    Source-only red/green evidence and candidate patch boundary from an isolated checkout, with no installed-runtime or live-service mutation.

    Scope

    • Base checkout: e0a83c0046
    • Files changed in the isolated source experiment:
      • src/agents/pi-embedded-runner/run/incomplete-turn.ts
      • src/agents/pi-embedded-runner/run.incomplete-turn.test.ts
    • Installed OpenClaw runtime, gateway, config, sessions, Telegram, cron, and resident services were not changed.

    Red test

    Added the failing regression first: retries direct Telegram progress-only message tool delivery with no work.

    Focused run before the source change:

    node scripts/run-vitest.mjs run --config test/vitest/vitest.agents-pi-embedded.config.ts src/agents/pi-embedded-runner/run.incomplete-turn.test.ts
    

    Result:

    1 failed | 90 passed
    expected "vi.fn()" to be called 2 times, but got 1 times
    

    That proves the current source completed after one progress-only committed message(action=send) delivery instead of retrying/continuing the actionable turn.

    Candidate patch boundary

    The prototype reuses resolvePlanningOnlyRetryInstruction rather than adding a separate terminal classifier. It treats committed message-tool text as visible planning/progress text only when it is the only visible output and there is no client tool, yield, deterministic approval prompt, tool error, committed media, substantive non-plan tool activity, or other continuation/progress evidence. Existing planning-only/actionable-prompt gates still apply.

    Candidate behavior:

    • Progress-only committed message text such as "I'm checking that now." on an actionable prompt triggers the existing planning-only act-now retry path.
    • Legitimate final message-only replies remain terminal success.
    • Progress/status message text after substantive tool activity remains terminal success and is not retried.
    • The retry attempt is marked with initialReplayState: { hadPotentialSideEffects: true, replayInvalid: true } because a visible message was already sent.

    Green verification

    Focused test after the patch:

    1 passed (1)
    94 passed (94)
    

    Changed-file checks passed on rerun after an initial sandbox fetch failed before validation. The successful rerun covered conflict markers, changelog attribution, wildcard re-export guards, duplicate-scan coverage, core typecheck, core test typecheck, core lint, runtime sidecar loader guard, runtime import cycles, webhook body guard, pairing store guard, and pairing account guard.

    git diff --check also passed.

    Maintainer decision needed

    This gives a narrow source-level fix option, but it relies on natural-language progress/planning classification. Please decide whether that heuristic is acceptable here, or whether the runtime should instead introduce an explicit message-tool semantic signal such as intent: "progress" | "final" / equivalent finality metadata so source-reply finality is not inferred from status text.

  10. epruseal commented on Jul 19, 2026

    @epruseal

    Additional Discord-channel confirmation, plus a quick post-update check on the release that appears to contain the fix.

    Environment

    • Before update: OpenClaw 2026.7.1 (2d2ddc4), embedded Codex app-server
    • After update: OpenClaw 2026.7.1-2 (0790d9f)
    • Model: gpt-5.5
    • Channel: Discord channel
    • Config: messages.groupChat.visibleReplies = message_tool, so source replies are delivered through the message-tool path

    Stable-channel behavior before update

    On 2026.7.1, the local trajectory/log pattern matched this issue:

    message tool.result succeeds
    turn.dynamic_tool_terminal_release  tool=message
    model/session records success
    no promised follow-up tool work runs
    

    Representative local gateway timing immediately before the update showed several codex app-server turn released after terminal dynamic tool result events from Discord-channel turns. The user-visible symptom was the same as the other reports here: the agent sent a visible progress/status message, then the rest of the intended work did not happen.

    Post-update check on 2026.7.1-2

    After updating and restarting the gateway/app-server, I ran the same practical scenario from a Discord channel: first send a visible progress message with message(action=send), then continue with ordinary tools in the same turn. This time the turn continued successfully: after the message send, the agent ran additional bash and message.read calls and completed the diagnosis. The current-turn trajectory contained no turn.dynamic_tool_terminal_release event.

    The installed bundled code also matches the expected fix shape: source-reply delivery is still recorded as delivery evidence, but withDynamicToolTermination(...) now guards termination with !confirmedSourceReply, so a successful source message delivery alone no longer releases the turn.

    Authorship disclosure: this was collected and privacy-scrubbed by the affected user's OpenClaw agent at the user's request. User/channel IDs, message bodies, local paths, and tool-call IDs are omitted.

  11. 9 remaining items

  12. jinngimk-lang commented on Aug 17, 2026

    @jinngimk-lang
  13. added
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    and removed
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on Aug 18, 2026
  14. self-assigned this
    on Aug 24, 2026
  15. added
    dedupe:childDuplicate issue/PR child in dedupe cluster
    duplicateThis issue or pull request already exists
    on Aug 24, 2026
  16. vincentkoc commented on Aug 24, 2026

    @vincentkoc
    Member

    Reviewed as a duplicate of #127139. Thanks @antonsbot for the original report and cross-channel reproduction trail.

    This closure does not mean the behavior is fixed. On current main a3f64c19b673469e45c80f351414e88b664e390e, a confirmed message_tool_only reply with omitted final is explicitly treated as final/terminal (dynamic-tools.ts:873-897, dynamic-tools.test.ts:2341-2358), and the successful terminal result schedules and performs a Codex turn release (run-attempt-server-requests.ts:325-337, run-attempt-lifecycle-controller.ts:39-77). That is the same remaining omitted-final contract tracked by #127139.

    I also checked the exact bundled upstream dependency, @openai/codex 0.148.0 (rust-v0.148.0, commit 3ba0f711642a888aec92a611a3f3b2211157ff89). Its dynamic-tool response contains only content items and success (item.rs:1563-1566); the app server submits that as a dynamic-tool result (dynamic_tools.rs:37-53). Turn completion remains a separate authoritative notification, while turn/interrupt is cancellation (README.md:81-83, README.md:209-212, turn_processor.rs:1443-1487). Tool completion therefore does not establish that the surrounding turn is complete.

    Closing this older report as a duplicate. Product/contract decisions and repair proof remain on #127139.

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

Metadata

Metadata

Assignees

Labels

P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.close:duplicateClosed as duplicatededupe:childDuplicate issue/PR child in dedupe clusterduplicateThis issue or pull request already existsimpact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions