Skip to content

[Bug]: Codex sessions_send can self-target the active Feishu session, causing lane wait and “Done.” empty-reply fallback #107172

Closed

Description

@collinsman

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

When using the official @openclaw/codex plugin with the OpenAI Codex runtime in a Feishu direct-message session, Codex generates the correct answer but sends it through OpenClaw's terminal message dynamic tool instead of returning it as the normal assistant final response.

The message tool successfully sends the complete answer as a separate Feishu message. However, the original Feishu streaming card receives no visible final assistant text. The Feishu reply dispatcher then treats the response as empty and inserts Done. using its empty-reply fallback.

A late native hook invocation also fails after the Codex turn has been released:

nativeHook.invoke ... errorCode=INVALID_REQUEST errorMessage=native hook relay not found

The same model and prompt work correctly when the Codex plugin/runtime is disabled and the OpenClaw Default runtime is used.

This appears to be an integration/state-synchronization issue between the Codex harness terminal message tool, Codex turn completion, native hook relay lifecycle, and Feishu streaming-card finalization.

Possibly related to:

#73723 / #73950 — native hook relay not found

#38686 — Feishu queuedFinal=false, replies=0

However, this reproduction is specific to OpenClaw 2026.7.1, the official Codex harness, a terminal message dynamic tool result, and Feishu streaming cards.

Steps to reproduce

1.Install OpenClaw and the official Codex plugin:
npm install -g [email protected]
openclaw plugins install @openclaw/codex

2.Enable the official Codex plugin:
{
plugins: {
allow: ["codex"],
entries: {
codex: {
enabled: true
}
}
}
}

3.Configure a Feishu channel with streaming replies enabled.

4.Select an eligible OpenAI model, for example:
openai/gpt-5.4-mini

5.Start a new session with /new or /reset.

6.Confirm with /status that the active runtime is:
Runtime: OpenAI Codex

7.Send a prompt that requires obtaining information and returning it in the reply, for example:
What is today's weather in Shenzhen? Include the actual result in the final reply and do not reply with only "Done".

8.Observe that Codex performs the task and calls the OpenClaw message dynamic tool to send the full answer.

9.Observe that the original Feishu streaming card contains only:
Done.

10.Disable the Codex plugin/runtime, run /new or /reset, and repeat the same prompt with the OpenClaw Default runtime.

11.Observe that the default runtime writes the complete answer directly into the original Feishu streaming card without the Done. fallback.

Relevant Codex-runtime log sequence:

deliverMessage: type=text ... textLen=234
deliverMessage: text sent
codex app-server turn released after terminal dynamic tool result
nativeHook.invoke ... errorCode=INVALID_REQUEST errorMessage=native hook relay not found
dispatch complete (queuedFinal=false, replies=0)
reply completed without visible text, using empty-reply fallback

Relevant OpenClaw Default runtime sequence:

cardElement.content ... contentLen=...
dispatch complete (queuedFinal=true, replies=3)
reply completed, card finalized

Confirmed reproduction in a fresh session

I repeated the test after applying:

{
  plugins: {
    entries: {
      codex: {
        enabled: true,
        config: {
          codexDynamicToolsExclude: ["message"]
        }
      }
    }
  }
}

I then ran /new in Feishu. OpenClaw confirmed:

New session started.
Context: 0/400k
Runtime: OpenAI Codex
Model: openai/gpt-5.4-mini

This rules out stale conversation history, an old Codex thread binding, and the previously cached dynamic-tool set.

The issue reproduced again in the fresh session. Because message was excluded, Codex used sessions_send instead. The tool targeted the same Feishu session that was already processing the parent turn.

Timeline:

13:06:17 Original Feishu turn starts.

13:11:51 sessions_send starts a nested agent run:
gateway/ws agent ... runId=39d14c37-...

13:12:22 The synchronous wait reaches 30 seconds:
agent.wait 30001ms

13:12:51 The nested run is blocked behind the active parent session:
lane wait exceeded:
lane=session:agent:tools:feishu:tools:direct:<redacted>
waitedMs=58203
queueAhead=0
activeAhead=1
activeNow=0
queueBehind=0

13:12:52 The original Feishu turn completes without a final reply:
dispatch complete (queuedFinal=false, replies=0)
elapsed=395010ms

13:12:53 Feishu inserts its empty-reply fallback:
reply completed without visible text, using empty-reply fallback

13:13:04 The nested agent finally generates the actual weather answer:
[agent:nested]
session=agent:tools:feishu:tools:direct:<same-redacted-session>
channel=webchat
深圳现在大概 30.3°C,体感约 36.1°C,湿度 75%……

The real answer was generated only after the original Feishu streaming card had already finalized with Done.. It was generated under channel=webchat and was not incorporated into the original Feishu response.

The Feishu UI showed:

Done.
Completed · 6m 36s · gpt-5.4-mini

This fresh-session reproduction confirms that:

  1. The bug is not caused by stale session history.
  2. The bug is not specific to the message dynamic tool.
  3. Codex can call sessions_send against its own currently active originating session.
  4. The nested request waits behind the parent session, creating a self-wait/session-lane dependency.
  5. The parent turn eventually completes with no final assistant text.
  6. Feishu inserts Done. as an empty-reply fallback.
  7. The actual nested answer arrives after the originating Feishu turn has already been finalized.

Expected safeguards

  • sessions_send should reject a synchronous send to the same currently active session, or convert it into a safe continuation that cannot wait behind itself.
  • Codex should not use sessions_send as the final reply mechanism for the originating conversation.
  • A nested result intended for the originating conversation should be incorporated into the parent assistant response before channel finalization.
  • Feishu should not display Done. when the runtime is still waiting for a nested result.
  • The parent turn should not remain active for several minutes because its nested request is queued behind that same parent turn.

This self-targeting behavior may also explain previously observed process/thread pressure under repeated Codex tool use, because repeated nested sends can create additional waits, agent runs, Active Memory calls, and runtime work attached to the same session.

Expected behavior

If Codex sends the final answer through the terminal message dynamic tool, OpenClaw should recognize that a user-visible reply has already been delivered.

The original Feishu streaming card should then either:

  • contain the same final answer;
  • finalize without adding another fallback response; or
  • be suppressed/closed cleanly because the terminal message already delivered the answer.

It should not display an additional Done. message.

The native hook relay should also remain valid until all turn-related hook invocations have completed, or late hook events should be handled without producing native hook relay not found.

Actual behavior

Codex successfully generates and sends the complete answer through the OpenClaw message dynamic tool.

Immediately afterward, OpenClaw releases the Codex app-server turn:

codex app-server turn released after terminal dynamic tool result

A late native hook invocation then fails:

nativeHook.invoke ... errorCode=INVALID_REQUEST errorMessage=native hook relay not found

The original Feishu dispatcher reports:

dispatch complete (queuedFinal=false, replies=0)

The streaming card detects that no visible final assistant text was received and inserts:

Done.

As a result, the user receives:

1.a streaming card containing only Done.; and

2.a separate message containing the actual answer.

The same model works correctly through the OpenClaw Default runtime.

Additional reproduction: excluding the message tool does not resolve the issue

I added the documented Codex dynamic-tool exclusion:

{
plugins: {
entries: {
codex: {
enabled: true,
config: {
codexDynamicToolsExclude: ["message"]
}
}
}
}
}


The Gateway confirmed that the configuration was applied:

```text
config change detected; evaluating reload
plugins.entries.codex.config
config hot reload applied

After excluding message, Codex no longer used the message tool. Instead, it executed the following sequence:

Run command
Sessions send
Openclawsessions send

The result was still an empty original assistant reply and a Feishu Done. fallback:

dispatch complete (queuedFinal=false, replies=0)
reply completed without visible text, using empty-reply fallback

This indicates that the issue is not specific to the message dynamic tool. It affects Codex turns that complete through tools without producing a normal final non-commentary assistant message.

There is also evidence that sessions_send targeted the same currently active Feishu session. The nested request waited behind the active parent work:

agent.wait 20006ms
lane wait exceeded:
lane=session:agent:tools:feishu:tools:direct:<redacted>
waitedMs=36728
activeAhead=1

The original Feishu turn completed with no reply after approximately 121 seconds:

dispatch complete (queuedFinal=false, replies=0, elapsed=121166ms)
reply completed without visible text, using empty-reply fallback

The nested agent generated the actual weather response only after the original Feishu streaming card had already been finalized with Done.:

[agent:nested]
session=agent:tools:feishu:tools:direct:<same-redacted-session>
深圳当前天气:小雨,9°C,气压 1002 hPa,湿度 84%,风速约 4 km/h。

[agent] run ... ended with stopReason=stop

Expected additional safeguards:

  • A Codex tool-only turn should not cause an unrelated Done. fallback when its tool output represents the user-visible result.
  • sessions_send should reject or safely handle attempts to synchronously target the same currently active session.
  • A nested result targeting the originating session should be delivered before the original channel turn is finalized, or the parent turn should produce a normal final assistant response.
  • The Feishu dispatcher should distinguish a deliberately silent/tool-delivered completion from a genuinely missing response.

This recursive/self-targeting sessions_send path may also contribute to session-lane waits, long response times, repeated Active Memory calls, and process/thread resource exhaustion under repeated use.

OpenClaw version

OpenClaw 2026.7.1 (2d2ddc4) @openclaw/codex 2026.7.1 Node.js v24.18.0

Operating system

AlmaLinux release 8.10 (Cerulean Leopard)

Install method

No response

Model

openai/gpt-5.4-mini

Provider / routing chain

Failing path: Feishu direct message → OpenClaw 2026.7.1 → official @openclaw/codex plugin → OpenAI Codex runtime → managed Codex app-server over stdio → openai/gpt-5.4-mini using ChatGPT/Codex OAuth → OpenClaw terminal message dynamic tool → separate Feishu message → original Feishu streaming card receives no final assistant text → empty-reply fallback displays “Done.” Working comparison path: Feishu direct message → OpenClaw 2026.7.1 → OpenClaw Default runtime → OpenAI ChatGPT Responses route → openai/gpt-5.4-mini → normal assistant final response → Feishu streaming card finalizes correctly Active Memory separately uses: deepseek/deepseek-v4-flash It returns HTTP 200 with status=no_relevant_memory and does not appear to be involved in this issue.

Additional provider/model setup details

No response

Logs

Screenshots, recordings, and evidence

No response

Impact and severity

No response

Additional information

No response

Activity

  1. added
    bug
    on Jul 14, 2026
  2. added
    regression
    on Jul 14, 2026
  3. clawsweeper commented on Jul 14, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 14, 2026, 7:31 AM ET / 11:31 UTC.

    Summary
    Keep this issue open. Current main still allows a synchronous sessions_send target to resolve to the originating active session and then starts and waits for the nested run, so the reported self-wait remains possible. The linked open PR addresses that guard but explicitly leaves Codex tool-delivery accounting, Feishu finalization, and late native-hook lifecycle handling unresolved.

    Reproducibility: yes. at source level: the report provides a fresh-session timeline, and current main still resolves, starts, and synchronously waits on a nested run without rejecting an originating-session target. A live current-main Feishu reproduction was not run during this read-only review.

    Root-cause cluster
    Relationship: canonical
    Canonical: #107172
    Summary: This issue is the canonical broader integration report; the linked PR is a partial candidate fix for its synchronous self-target failure mode, while older Feishu and relay reports share symptoms or adjacent infrastructure without proving the same complete root cause.

    Members:

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

    Next step
    The open linked PR already owns the narrow self-target safeguard, and the remaining work spans coordinated Codex, Feishu, and hook-lifecycle boundaries rather than a safe competing autonomous fix.

    Review details

    Best possible solution:

    Land or supersede the linked post-resolution self-target guard, then keep this issue as the canonical integration track until Codex tool-delivered output is reflected in parent reply accounting, Feishu finalizes deliberate tool-delivered completions without an unrelated fallback, and relay teardown waits for all turn-related native-hook activity; validate the complete behavior with a fresh real Feishu session.

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

    Yes at source level: the report provides a fresh-session timeline, and current main still resolves, starts, and synchronously waits on a nested run without rejecting an originating-session target. A live current-main Feishu reproduction was not run during this read-only review.

    Is this the best way to solve the issue?

    Partly. The linked PR is the narrowest appropriate fix for the self-wait invariant, but it intentionally does not solve the broader Codex reply-accounting, Feishu finalization, and late native-hook lifecycle defects that must remain tracked here.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Landing only the linked self-target guard prevents the predictable lane deadlock but can still leave Codex tool-delivered replies unaccounted for by the parent turn, allowing Feishu to finalize with fallback text.
    • The reported late nativeHook.invoke failure may be a separate relay teardown-timing defect from the duplicate-module registry bug already fixed by fix(codex): share native hook relay registry #73950; it needs focused lifecycle proof rather than being assumed fixed.
    • No live current-main Feishu/Codex reproduction was executed during this read-only review, so the exact interaction among reply accounting, card finalization, and relay teardown remains source-supported but not end-to-end proven on the latest SHA.

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

    Label changes

    Label changes:

    • add P1: A released optional runtime can stall an active channel turn for minutes and fail to place the generated answer in the originating Feishu reply.
    • add impact:message-loss: The expected answer is omitted from the originating Feishu response and replaced by fallback text, while the nested result arrives too late or through a separate delivery path.
    • add impact:session-state: A nested synchronous request can resolve to and wait behind the same active session that initiated it, creating a self-dependency in the session lane.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.

    Label justifications:

    • P1: A released optional runtime can stall an active channel turn for minutes and fail to place the generated answer in the originating Feishu reply.
    • impact:message-loss: The expected answer is omitted from the originating Feishu response and replaced by fallback text, while the nested result arrives too late or through a separate delivery path.
    • impact:session-state: A nested synchronous request can resolve to and wait behind the same active session that initiated it, creating a self-dependency in the session lane.
    Evidence reviewed

    What I checked:

    • Current-main self-target path: The sessions tool resolves the target and records sameSessionA2A, but current main uses that fact for policy/hook context rather than rejecting a synchronous send back to the originating session. (src/agents/tools/sessions-send-tool.ts:342, c1b55ffab7a2)
    • Current-main synchronous wait: After target resolution, the tool starts a nested agent run and calls agent.wait when timeoutSeconds is nonzero; no same-origin synchronous guard appears before that wait. (src/agents/tools/sessions-send-tool.ts:671, c1b55ffab7a2)
    • Feishu symptom remains downstream: The Feishu dispatcher still substitutes fallback text when a completed reply contains no visible content. Current main uses a more explanatory fallback than release 2026.7.1, but that does not recover or incorporate the nested answer into the originating turn. (extensions/feishu/src/reply-dispatcher.ts:530, c1b55ffab7a2)
    • Codex turn contract: Upstream Codex app-server models dynamic tool calls as request/response interactions within a turn, while turn/completed is a separate terminal event. This supports treating terminal-tool-result release and parent-reply accounting as an OpenClaw integration concern rather than assuming a tool result is automatically the assistant final response. (codex-rs/app-server/README.md)
    • Linked candidate fix: The open linked PR rejects synchronous self-target sends after aliases and labels resolve, while retaining asynchronous timeoutSeconds: 0 self-sends. Its description explicitly says it does not resolve Codex terminal-message accounting, Feishu finalization, or native-hook lifecycle symptoms. (src/agents/tools/sessions-send-tool.ts, 1712bed35e12)
    • Issue reproduction evidence: The reporter supplied a fresh-session timeline showing sessions_send target the same Feishu session, wait behind the active parent lane, let the parent finalize empty, and generate the nested answer only afterward. Excluding the message dynamic tool reproduced the same failure through sessions_send.

    Likely related people:

    • aktayal: Authored the linked focused PR implementing the post-resolution synchronous self-target guard and documenting the remaining Codex, Feishu, and relay-lifecycle scope. (role: candidate fix author; confidence: high; commits: 1712bed35e12; files: src/agents/tools/sessions-send-tool.ts)
    • steipete: Recent current-main history on the sessions tool includes context propagation and sessions tool refactoring that shaped the originating-session and A2A path involved here. (role: recent area contributor; confidence: medium; commits: 42d6e35, 7cb6553, bcbfb35; files: src/agents/tools/sessions-send-tool.ts)
    • Thesaranshn8n: Authored the merged native-hook relay registry repair referenced by the report, making them relevant to distinguishing the earlier registry failure from the remaining teardown-timing symptom. (role: adjacent relay fix author; confidence: medium; commits: 6729dea36f75; files: src/agents/harness/native-hook-relay.ts, extensions/codex/src/app-server/native-hook-relay.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  4. added
    P1
    impact:message-loss
    impact:session-state
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    on Jul 14, 2026
  5. locked as resolved and limited conversation to collaborators on Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1bugclawsweeper:source-reproimpact:message-lossimpact:session-stateissue-rating: 🦞 diamond lobsterregression

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions