Repository navigation
Description
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:
- The bug is not caused by stale session history.
- The bug is not specific to the
messagedynamic tool. - Codex can call
sessions_sendagainst its own currently active originating session. - The nested request waits behind the parent session, creating a self-wait/session-lane dependency.
- The parent turn eventually completes with no final assistant text.
- Feishu inserts
Done.as an empty-reply fallback. - The actual nested answer arrives after the originating Feishu turn has already been finalized.
Expected safeguards
sessions_sendshould 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_sendas 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_sendshould 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
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jul 14, 2026
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
mainstill allows a synchronoussessions_sendtarget 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
mainstill 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:
canonicalCanonical: #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:
fixed_by_candidate: fix: synchronous sessions_send self-targets time out #107267 - The open PR directly fixes the synchronous same-originsessions_sendself-wait but explicitly leaves the remaining Codex, Feishu, and relay-lifecycle behavior to this issue.partial_overlap: [Bug]: Feishu Channel Fails to Send Replies Despite Successful Agent Processing #38686 - It reports the same FeishuqueuedFinal=false, replies=0symptom on an older release, but lacks evidence tying it to Codex self-targeting or the same session-lane dependency.adjacent_distinct: Native hook relay remains unavailable after gateway restart and hooks report 5/5 ready #73723 - It concerns persistent absence of a Codex native-hook relay after restart, whereas this issue reports a late invocation after turn release plus a separate self-target wait.adjacent_distinct: fix(codex): share native hook relay registry #73950 - The merged PR repairs shared relay registry state across duplicate modules but does not implement the self-target guard or parent reply/finalization behavior.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
mainstill 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:
nativeHook.invokefailure 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.Codex review notes: model internal, reasoning high; reviewed against c1b55ffab7a2.
Label changes
Label changes:
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.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.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:
sameSessionA2A, but currentmainuses 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)agent.waitwhentimeoutSecondsis nonzero; no same-origin synchronous guard appears before that wait. (src/agents/tools/sessions-send-tool.ts:671, c1b55ffab7a2)mainuses 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)turn/completedis 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)timeoutSeconds: 0self-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)sessions_sendtarget the same Feishu session, wait behind the active parent lane, let the parent finalize empty, and generate the nested answer only afterward. Excluding themessagedynamic tool reproduced the same failure throughsessions_send.Likely related people:
src/agents/tools/sessions-send-tool.ts)src/agents/tools/sessions-send-tool.ts)src/agents/harness/native-hook-relay.ts,extensions/codex/src/app-server/native-hook-relay.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.fix(agents): reject synchronous sessions_send self-targets, break dow…
fix(agents): reject synchronous sessions_send self-targets, break dow…