Repository navigation
feat(openai): support Astra async tools, steering, and effort updates - #138046
Conversation
Run direct function tools while Astra continues generating, accept user steering on cached Responses WebSockets, and preserve the prompt prefix when reasoning effort changes. Keep tool admission and transcript ownership in the existing runtime, and preserve actual input delivery order when replaying saved conversations.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Finalize through the wrapped result contract and retain unchanged content identity so code-mode source survives transcript persistence. Fence queued tools before result hooks can yield. Simplify redundant streaming and replay conditions, move a stray test import, and make the steering immutability assertion inspect its actual input.
|
@clawsweeper re-review The final head is ready for landing: all 439 focused tests, five authenticated live scenarios, local changed-file gates, and required hosted CI passed. The independent review findings have been repaired; details and proof are in the PR body. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: blocked before merge. Reviewed September 4, 2026, 5:30 AM ET / 09:30 UTC. ClawSweeper reviewWhat this changesAdds Astra-only asynchronous function tools, mid-turn steering over cached OpenAI Responses WebSockets, and cache-preserving reasoning-effort updates to OpenClaw’s built-in runtime. Merge readiness⛔ Blocked before merge - 4 items remain Keep this PR open for its intended feature work. The current agent and transport boundaries appear coherent, but no inspectable authenticated Astra trace independently verifies the new OpenAI protocol path; recent Responses-runtime history makes steipete a likely routing candidate. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s built-in agent runtime streams model responses, runs admitted tools, and stores conversation state for subsequent turns. The change extends the official OpenAI Responses path while feeding results and accepted user input back through the normal transcript and continuation flow. flowchart LR
A[Queued user input] --> B[Built-in agent runtime]
B --> C[OpenAI Responses WebSocket]
C --> D[Async tools and live steering]
D --> E[Transcript and continuation]
E --> F[Next agent turn]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1236, Tests +2632, Docs +51, Other 0. Total +3919 across 31 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the narrow Astra and official-endpoint gates, and attach a redacted authenticated Astra trace covering an async tool, accepted steering, and an effort update before merge. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds a new provider-runtime capability rather than repairing a reported current-main defect. Is this the best way to solve the issue? Unclear: the feature is implemented at the stream, transcript, and continuation owners rather than through a downstream workaround, but the external API contract has not been independently verified. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e0c230789b33. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…openclaw#138046) * feat(openai): support Astra async tools, steering, and effort updates Run direct function tools while Astra continues generating, accept user steering on cached Responses WebSockets, and preserve the prompt prefix when reasoning effort changes. Keep tool admission and transcript ownership in the existing runtime, and preserve actual input delivery order when replaying saved conversations. * fix(agents): preserve response ownership during async finalization Finalize through the wrapped result contract and retain unchanged content identity so code-mode source survives transcript persistence. Fence queued tools before result hooks can yield. Simplify redundant streaming and replay conditions, move a stray test import, and make the steering immutability assertion inspect its actual input. * fix(agents): honor finalized calls and early steering rejection
… running (#157212) ## What Problem This Solves Fixes: with OpenAI Responses async tool calls, a tool that is still running gets a fake `aborted` error result in the session transcript when the model writes a closing text fragment in the same response. ## User Impact User impact: the transcript and session views show each async tool call's real outcome once, instead of a false `aborted` failure followed by a duplicate real result. ## Why This Change Was Made Regression from #138046: async tool execution commits each tool call as its own fragment of one provider response while the response keeps streaming. The session tool-result guard treated any later tool-free assistant message as a turn boundary and synthesized `aborted` results for every pending call, including calls from the response that was still streaming. The real result then arrived under the same call ID. The guard now records the identities (`responseId` and the runtime `turnId`) of the latest assistant message that added pending calls. A later fragment that shares either identity no longer ends them; this covers a tool fragment stored with only its runtime `turnId` whose final fragment also gains the late provider `responseId`. An assistant message from a different response still synthesizes missing results as before. The trigger is common because the deferred `sessions_yield` result (#146667) tells the model to finish its response while earlier async results are unobserved, and the model finishes with a short status text. ## Compatibility No stored format, schema, or config change. The guard only stops writing synthetic `aborted` rows for calls whose response is still streaming. Existing transcripts that already contain a synthetic row plus the later real result are unchanged; transcript repair already prefers the real result when replaying them. Upgrade and rollback, observed with live turns on one isolated state, using an OpenAI Responses model with async tool calls (OpenClaw runtime, code mode off): | Session written by | Continued on | Follow-up turn ("what did that command print?", no tools) | | --- | --- | --- | | base `340cb1c8402` (stored a synthetic `aborted` row plus the real result for the same call) | this branch | replied `PROOF_DONE`; the stored rows were read unchanged | | this branch (one result per call) | base `340cb1c8402` | replied `PROOF_DONE` | ## Evidence Production trace (OpenClaw runtime, Telegram topic, OpenAI Responses async tool calls): 11 tool calls received an `aborted` error result followed later by their real result under the same call ID; 10 of them followed a deferred `sessions_yield`. The owning files are unchanged between that serving commit and this base. Live E2E, local CLI (`openclaw agent --local`), isolated state, OpenAI API key, an OpenAI Responses model with async tool calls on the OpenClaw runtime, code mode off, same prompt on both builds (start `sleep 20 && echo PROOF_DONE` with `exec`, say it is running, then report the output). Both runs produced async `exec`/`process` calls, a deferred `sessions_yield`, and a text-only fragment while `process` was still running. | Transcript | base `340cb1c8402` | this branch | | --- | --- | --- | | `process` results | `aborted` (error) at 16:00:56, real output at 16:01:07 | real output only (rerun on the final head: same) | | Results per call | 2 for `process` | 1 for every call | | Final reply | `PROOF_DONE` | `PROOF_DONE` | Tests: - New regression `keeps async tool calls pending across later fragments of the same response` covers the provider-response-id case and the carried-turn-id-with-late-response-id case; both fail on base (`expected [] to strictly equal [ 'call_1' ]`) and pass here. Control `synthesizes results before an assistant message from a later response` passes on both. - `session-tool-result-guard*.test.ts` + `agent-loop.async-yield.test.ts` (120), `session-tool-result-guard.persistence-order`/`visibility` suites (30, 37), `sessions-yield-tool.test.ts` (4), `session-transcript-repair.test.ts` (14): pass. - `pnpm tsgo:core` and `oxfmt --check`: pass. - Cost: the two new tests take 16 ms and 1 ms; `pnpm test src/agents/session-tool-result-guard.test.ts --maxWorkers=1` wall is 34 s, dominated by existing startup/imports. Co-authored-by: Ayaan Zaidi <[email protected]>
… running (openclaw#157212) ## What Problem This Solves Fixes: with OpenAI Responses async tool calls, a tool that is still running gets a fake `aborted` error result in the session transcript when the model writes a closing text fragment in the same response. ## User Impact User impact: the transcript and session views show each async tool call's real outcome once, instead of a false `aborted` failure followed by a duplicate real result. ## Why This Change Was Made Regression from openclaw#138046: async tool execution commits each tool call as its own fragment of one provider response while the response keeps streaming. The session tool-result guard treated any later tool-free assistant message as a turn boundary and synthesized `aborted` results for every pending call, including calls from the response that was still streaming. The real result then arrived under the same call ID. The guard now records the identities (`responseId` and the runtime `turnId`) of the latest assistant message that added pending calls. A later fragment that shares either identity no longer ends them; this covers a tool fragment stored with only its runtime `turnId` whose final fragment also gains the late provider `responseId`. An assistant message from a different response still synthesizes missing results as before. The trigger is common because the deferred `sessions_yield` result (openclaw#146667) tells the model to finish its response while earlier async results are unobserved, and the model finishes with a short status text. ## Compatibility No stored format, schema, or config change. The guard only stops writing synthetic `aborted` rows for calls whose response is still streaming. Existing transcripts that already contain a synthetic row plus the later real result are unchanged; transcript repair already prefers the real result when replaying them. Upgrade and rollback, observed with live turns on one isolated state, using an OpenAI Responses model with async tool calls (OpenClaw runtime, code mode off): | Session written by | Continued on | Follow-up turn ("what did that command print?", no tools) | | --- | --- | --- | | base `43cb361c447` (stored a synthetic `aborted` row plus the real result for the same call) | this branch | replied `PROOF_DONE`; the stored rows were read unchanged | | this branch (one result per call) | base `43cb361c447` | replied `PROOF_DONE` | ## Evidence Production trace (OpenClaw runtime, Telegram topic, OpenAI Responses async tool calls): 11 tool calls received an `aborted` error result followed later by their real result under the same call ID; 10 of them followed a deferred `sessions_yield`. The owning files are unchanged between that serving commit and this base. Live E2E, local CLI (`openclaw agent --local`), isolated state, OpenAI API key, an OpenAI Responses model with async tool calls on the OpenClaw runtime, code mode off, same prompt on both builds (start `sleep 20 && echo PROOF_DONE` with `exec`, say it is running, then report the output). Both runs produced async `exec`/`process` calls, a deferred `sessions_yield`, and a text-only fragment while `process` was still running. | Transcript | base `43cb361c447` | this branch | | --- | --- | --- | | `process` results | `aborted` (error) at 16:00:56, real output at 16:01:07 | real output only (rerun on the final head: same) | | Results per call | 2 for `process` | 1 for every call | | Final reply | `PROOF_DONE` | `PROOF_DONE` | Tests: - New regression `keeps async tool calls pending across later fragments of the same response` covers the provider-response-id case and the carried-turn-id-with-late-response-id case; both fail on base (`expected [] to strictly equal [ 'call_1' ]`) and pass here. Control `synthesizes results before an assistant message from a later response` passes on both. - `session-tool-result-guard*.test.ts` + `agent-loop.async-yield.test.ts` (120), `session-tool-result-guard.persistence-order`/`visibility` suites (30, 37), `sessions-yield-tool.test.ts` (4), `session-transcript-repair.test.ts` (14): pass. - `pnpm tsgo:core` and `oxfmt --check`: pass. - Cost: the two new tests take 16 ms and 1 ms; `pnpm test src/agents/session-tool-result-guard.test.ts --maxWorkers=1` wall is 34 s, dominated by existing startup/imports. Co-authored-by: Ayaan Zaidi <[email protected]>
…sync tools (#166876) ## What Problem This Solves Fixes: with GPT-6 Astra async tools, the model's real answer was lost when it called `sessions_yield` to wait for its own parallel tool results. Telegram received only a short follow-up "supplement", never the answer itself. On our setup (Telegram forum topic, `openai/gpt-6-astra`, built-in runtime), one response ran `memory_search`, `exec` and `read` in parallel. It then wrote commentary plus `sessions_yield` ("Await source rows exec + memory recall + planning ref read"), and then, still in the same response, a 2,967-character `final_answer` checklist. The model wrote that checklist before seeing any tool result. A second model call (no new user input) saw the results and wrote a 332-character note: "One additional booking to check…". Only the note was sent. ## User Impact When Astra waits for its own async tool results with `sessions_yield`, the response now really pauses. The model sees the results first and writes one complete answer. There are no new messages, notices or settings. ## Why This Change Was Made The model's wait tool was not allowed to wait. - #138046 (`a637374e435`) added Astra async tools and marks **every** function tool `async: true` (`openai-responses-client.ts`, `prepareRequest`), including `sessions_yield`. OpenAI's [async tool guide](https://developers.openai.com/api/docs/guides/async-tool-calling#add-a-wait-tool) says a wait tool must be an ordinary synchronous function: a sync call pauses the response, and the next request delivers the async results before the wait status. Because `sessions_yield` was async, Astra kept generating after the yield and answered without the results. - The `sessions_yield` deferral (`hasUnobservedAsyncToolResults`, from #146667 `2f663805b4c`, reworded as `deferred` in #149983 `e252366ffe2`) was **not** spurious. The results were already in the transcript, but async results only reach the model in the next request, so the model had not seen them. The gate correctly keeps the yield from ending the turn. Its old text ("Finish this response to receive them") could never help, because the model only reads it in that next request. The fix, at the owners: - `Tool.async?: false` (llm-core) lets a tool opt out of async calls. The Responses transport keeps such tools synchronous and still marks every other function tool async. The two session tool projections that pick fields (`projectAgentToolDefinition`, `wrapToolDefinition`) carry the flag next to `executionMode`. The closed worker tool-surface schema (`WorkerToolSurfaceSchema`) accepts it, so worker-environment turns that carry `sessions_yield` still start. - `sessions_yield` sets `async: false`. Its deferral now says what is true for a synchronous yield: the earlier results arrive with this result. - `async: false` is documented as a supported tool property in `docs/plugins/tool-plugins.md`, next to `executionMode`, `hideFromChannelProgress` and `catalogMode`. Plugins can already reach it through `api.registerTool`. Other providers, Code Mode and Tool Search catalog calls are unchanged. Maintainer decision (API direction): `async: false` is accepted as a supported, additive tool property. Scope: it keeps a directly visible function tool synchronous on GPT-6 Astra async-tool requests. Other providers, Code Mode and Tool Search catalog calls are unchanged. We chose this over a private carrier because the field is already reachable through `api.registerTool`, and a second private path (a transport option listing synchronous tool names) would add more code across agent-core stream options and the worker native runtime. Kept from earlier decisions: the deferral gate and its non-error `deferred` status (#146667, #149983), and async execution for every other direct tool (#138046). Code Mode and non-Astra routes are untouched. Not changed: other ways the model might wait, such as `process` polling. Boundaries a `sessions_yield` definition crosses on its way to an Astra async-tool request: the local and sub-agent session projections (both carry the flag), the shared `prepareRequest` (used by SSE, WebSocket, steering continuation, and compaction or retry rebuilds), and the worker tool surface (schema fixed here; the worker side spreads the definition). The native worker runtime passes `context.tools` through unchanged. Gateway-placed worker inference copies only name, description and parameters, but that path never enables async tool execution, so no tool is async there. Ordinary local turns do not cross the worker surface; its only producer is `src/gateway/worker-environments/worker-turn-execution.ts:358`. ## Evidence **Regressions** - `packages/ai/src/transports/openai-responses-client.continuation.test.ts`: the real `createSessionsYieldTool` and a plain tool go through the real session projections (`toToolDefinitions` → `wrapToolDefinition`) into the real Responses transport for `gpt-6-astra` with async tools on. The test asserts `exec` is sent `async: true` and `sessions_yield` is not. With the transport fix reverted it **fails** (`sessions_yield` is sent with `"async": true`). On this branch it passes (47 tests). - `src/gateway/worker-environments/worker-gateway-tool-runtime.test.ts`: the gateway issues the real `sessions_yield` through `getSurface`, and the surface must validate and keep `async: false`. With the schema line reverted it **fails** with `Worker tool surface is invalid` (the round-1 review blocker: worker turns could not start). - Also green on the final code: `prepared-tool-surface`, `agent-tool-definition-adapter*`, `tool-definition-wrapper`, `worker.runtime`, `worker-gateway-tools`, `worker-turn-rpc`, `sessions-yield-tool` (11 files, 230 tests), `pnpm tsgo:core`, `pnpm tsgo:core:test`, oxfmt/oxlint on changed files, `docs:check-links`, `docs:check-mdx`, `git diff --check`. **Live: Telegram Test Server with real `gpt-6-astra`.** Each run used its own forum topic and an isolated gateway on built `dist` (state under `/tmp`). The config matches our setup: the official `https://api.openai.com/v1` endpoint (async tools on), built-in runtime, code mode off, tool search on, `streaming.progress` with tool progress and commentary, thinking `low`. After the round-1 fix the build was `08acaf0afac`, which has the same code as this head (only `docs/plugins/tool-plugins.md` changed since). Message ids are the userbot's. Incident shape (a). Same prompt both sides: a rough card list, then "start both checks together: cat card-export.csv with exec and open trip-notes.md with the read tool, and call sessions_yield to wait for them. Don't hold the checklist for the files: right after the sessions_yield call, write the dated checklist from my list; when the results arrive, add only what they change." The files hold two facts the list lacks: the hotel was personal, and one dinner was split four ways. | | `origin/main` `c73c99d9e03` | this PR (`08acaf0afac` build) | | --- | --- | --- | | `sessions_yield` call | `async: true`, `deferred` | synchronous, `deferred` ("arrive with this result") | | Response 1 after the yield | kept generating a 416-token "**Provisional Splitwise checklist**" `final_answer` before any result arrived | ends at the yield call (`toolUse`) | | Response 2 | "Two corrections from the files: …" | the full checklist plus "File-check changes: Hotel: exclude … Jalan Alor: four ways, ₹1,102.50 each …" | | Model requests | 2 | 2 | | Bot messages (userbot view) | 1: msg 39, "Two corrections from the files: …". **The checklist never arrived.** | 1: msg 90, "Splitwise checklist — 8 October 2026 / From your rough list … File-check changes … Final shared total: ₹88,944 …" | Both sides also posted a progress draft (`Working / Exec / Read…`), which was deleted when the answer landed. Sibling runs on the same build: | Case | Model path | Bot messages (userbot) | | --- | --- | --- | | (b) sub-agent: `sessions_spawn` → `sessions_yield` → completion | yield `deferred`, then `yielded`; the completion wake writes the answer | msg 43 once: "Dev skipped the Jalan Alor dinner. The ₹4,410 bill is split four ways: … ₹1,102.50 …"; draft deleted | | (c) background `exec` (`sleep 30; echo BG-…-done`) with completion wake | exec background; yield `deferred`, then `nothing_pending`; short waiting reply; the exit wake writes the output | msg 97 "Running in the background. I'll report its exact output when it finishes.", then msg 98 "BG-5C861F-done" once | | (e) plain single-tool turn ("read trip-notes.md, who skipped the dinner?") | `read` (async), then a synchronous yield `deferred`; one answer | msg 99 "Dev skipped the Jalan Alor dinner." once; draft deleted | | (d) `NO_REPLY` on a direct user request | model says `NO_REPLY`; the required-reply retry asks for a visible answer | msg 69 "Noted for this thread." **Same on `origin/main`** (`c73c99d9e03`): msg 95 "Noted for this thread." | On (d): every live `NO_REPLY` shape we tried reached a reply contract that requires visible text, and this PR changes none of that code. A direct user request in a group is a required-reply turn. After a yield, the requester's completion wake must produce a visible final ("A yield owes the conversation a visible final unless private findings let the requester choose silence", `subagent-announce.requester-settle-state.ts:170-172`). The three completion-wake runs showed the same retry (`empty response detected … visible-answer continuation`). Ambient room events never reached the model. The user-request case matches `origin/main` exactly. (f) worker-placed turn: our setup has no worker environments, so ordinary turns never cross the worker surface. The worker regression above covers it. LOC vs `origin/main`: production +19/−2 (7 files), tests +36, docs +18/−5. ## Bounded cost - Runtime: one `Set` built from the request's tool list, only on Astra async-tool requests. No new requests, timers, state, settings or messages. A yield that waits for async results no longer produces a blind answer, so the incident case saves one wasted answer of about 400 output tokens. - Live proof spend: about $8.56 of `gpt-6-astra` across 20 Telegram Test Server runs. That is $3.59 for exploration and the first before/after pair, and $4.97 for the final-head siblings and the `origin/main` `NO_REPLY` baseline. Figures are summed from transcript usage costs, including sub-agents. Every run-owned forum topic has been deleted. Co-authored-by: Ayaan Zaidi <[email protected]>
…sync tools (openclaw#166876) ## What Problem This Solves Fixes: with GPT-6 Astra async tools, the model's real answer was lost when it called `sessions_yield` to wait for its own parallel tool results. Telegram received only a short follow-up "supplement", never the answer itself. On our setup (Telegram forum topic, `openai/gpt-6-astra`, built-in runtime), one response ran `memory_search`, `exec` and `read` in parallel. It then wrote commentary plus `sessions_yield` ("Await source rows exec + memory recall + planning ref read"), and then, still in the same response, a 2,967-character `final_answer` checklist. The model wrote that checklist before seeing any tool result. A second model call (no new user input) saw the results and wrote a 332-character note: "One additional booking to check…". Only the note was sent. ## User Impact When Astra waits for its own async tool results with `sessions_yield`, the response now really pauses. The model sees the results first and writes one complete answer. There are no new messages, notices or settings. ## Why This Change Was Made The model's wait tool was not allowed to wait. - openclaw#138046 (`8995a7eeac9`) added Astra async tools and marks **every** function tool `async: true` (`openai-responses-client.ts`, `prepareRequest`), including `sessions_yield`. OpenAI's [async tool guide](https://developers.openai.com/api/docs/guides/async-tool-calling#add-a-wait-tool) says a wait tool must be an ordinary synchronous function: a sync call pauses the response, and the next request delivers the async results before the wait status. Because `sessions_yield` was async, Astra kept generating after the yield and answered without the results. - The `sessions_yield` deferral (`hasUnobservedAsyncToolResults`, from openclaw#146667 `6293548dcd5`, reworded as `deferred` in openclaw#149983 `5f070d3ee30`) was **not** spurious. The results were already in the transcript, but async results only reach the model in the next request, so the model had not seen them. The gate correctly keeps the yield from ending the turn. Its old text ("Finish this response to receive them") could never help, because the model only reads it in that next request. The fix, at the owners: - `Tool.async?: false` (llm-core) lets a tool opt out of async calls. The Responses transport keeps such tools synchronous and still marks every other function tool async. The two session tool projections that pick fields (`projectAgentToolDefinition`, `wrapToolDefinition`) carry the flag next to `executionMode`. The closed worker tool-surface schema (`WorkerToolSurfaceSchema`) accepts it, so worker-environment turns that carry `sessions_yield` still start. - `sessions_yield` sets `async: false`. Its deferral now says what is true for a synchronous yield: the earlier results arrive with this result. - `async: false` is documented as a supported tool property in `docs/plugins/tool-plugins.md`, next to `executionMode`, `hideFromChannelProgress` and `catalogMode`. Plugins can already reach it through `api.registerTool`. Other providers, Code Mode and Tool Search catalog calls are unchanged. Maintainer decision (API direction): `async: false` is accepted as a supported, additive tool property. Scope: it keeps a directly visible function tool synchronous on GPT-6 Astra async-tool requests. Other providers, Code Mode and Tool Search catalog calls are unchanged. We chose this over a private carrier because the field is already reachable through `api.registerTool`, and a second private path (a transport option listing synchronous tool names) would add more code across agent-core stream options and the worker native runtime. Kept from earlier decisions: the deferral gate and its non-error `deferred` status (openclaw#146667, openclaw#149983), and async execution for every other direct tool (openclaw#138046). Code Mode and non-Astra routes are untouched. Not changed: other ways the model might wait, such as `process` polling. Boundaries a `sessions_yield` definition crosses on its way to an Astra async-tool request: the local and sub-agent session projections (both carry the flag), the shared `prepareRequest` (used by SSE, WebSocket, steering continuation, and compaction or retry rebuilds), and the worker tool surface (schema fixed here; the worker side spreads the definition). The native worker runtime passes `context.tools` through unchanged. Gateway-placed worker inference copies only name, description and parameters, but that path never enables async tool execution, so no tool is async there. Ordinary local turns do not cross the worker surface; its only producer is `src/gateway/worker-environments/worker-turn-execution.ts:358`. ## Evidence **Regressions** - `packages/ai/src/transports/openai-responses-client.continuation.test.ts`: the real `createSessionsYieldTool` and a plain tool go through the real session projections (`toToolDefinitions` → `wrapToolDefinition`) into the real Responses transport for `gpt-6-astra` with async tools on. The test asserts `exec` is sent `async: true` and `sessions_yield` is not. With the transport fix reverted it **fails** (`sessions_yield` is sent with `"async": true`). On this branch it passes (47 tests). - `src/gateway/worker-environments/worker-gateway-tool-runtime.test.ts`: the gateway issues the real `sessions_yield` through `getSurface`, and the surface must validate and keep `async: false`. With the schema line reverted it **fails** with `Worker tool surface is invalid` (the round-1 review blocker: worker turns could not start). - Also green on the final code: `prepared-tool-surface`, `agent-tool-definition-adapter*`, `tool-definition-wrapper`, `worker.runtime`, `worker-gateway-tools`, `worker-turn-rpc`, `sessions-yield-tool` (11 files, 230 tests), `pnpm tsgo:core`, `pnpm tsgo:core:test`, oxfmt/oxlint on changed files, `docs:check-links`, `docs:check-mdx`, `git diff --check`. **Live: Telegram Test Server with real `gpt-6-astra`.** Each run used its own forum topic and an isolated gateway on built `dist` (state under `/tmp`). The config matches our setup: the official `https://api.openai.com/v1` endpoint (async tools on), built-in runtime, code mode off, tool search on, `streaming.progress` with tool progress and commentary, thinking `low`. After the round-1 fix the build was `08acaf0afac`, which has the same code as this head (only `docs/plugins/tool-plugins.md` changed since). Message ids are the userbot's. Incident shape (a). Same prompt both sides: a rough card list, then "start both checks together: cat card-export.csv with exec and open trip-notes.md with the read tool, and call sessions_yield to wait for them. Don't hold the checklist for the files: right after the sessions_yield call, write the dated checklist from my list; when the results arrive, add only what they change." The files hold two facts the list lacks: the hotel was personal, and one dinner was split four ways. | | `origin/main` `a2ab6c2cf57` | this PR (`08acaf0afac` build) | | --- | --- | --- | | `sessions_yield` call | `async: true`, `deferred` | synchronous, `deferred` ("arrive with this result") | | Response 1 after the yield | kept generating a 416-token "**Provisional Splitwise checklist**" `final_answer` before any result arrived | ends at the yield call (`toolUse`) | | Response 2 | "Two corrections from the files: …" | the full checklist plus "File-check changes: Hotel: exclude … Jalan Alor: four ways, ₹1,102.50 each …" | | Model requests | 2 | 2 | | Bot messages (userbot view) | 1: msg 39, "Two corrections from the files: …". **The checklist never arrived.** | 1: msg 90, "Splitwise checklist — 8 October 2026 / From your rough list … File-check changes … Final shared total: ₹88,944 …" | Both sides also posted a progress draft (`Working / Exec / Read…`), which was deleted when the answer landed. Sibling runs on the same build: | Case | Model path | Bot messages (userbot) | | --- | --- | --- | | (b) sub-agent: `sessions_spawn` → `sessions_yield` → completion | yield `deferred`, then `yielded`; the completion wake writes the answer | msg 43 once: "Dev skipped the Jalan Alor dinner. The ₹4,410 bill is split four ways: … ₹1,102.50 …"; draft deleted | | (c) background `exec` (`sleep 30; echo BG-…-done`) with completion wake | exec background; yield `deferred`, then `nothing_pending`; short waiting reply; the exit wake writes the output | msg 97 "Running in the background. I'll report its exact output when it finishes.", then msg 98 "BG-5C861F-done" once | | (e) plain single-tool turn ("read trip-notes.md, who skipped the dinner?") | `read` (async), then a synchronous yield `deferred`; one answer | msg 99 "Dev skipped the Jalan Alor dinner." once; draft deleted | | (d) `NO_REPLY` on a direct user request | model says `NO_REPLY`; the required-reply retry asks for a visible answer | msg 69 "Noted for this thread." **Same on `origin/main`** (`a2ab6c2cf57`): msg 95 "Noted for this thread." | On (d): every live `NO_REPLY` shape we tried reached a reply contract that requires visible text, and this PR changes none of that code. A direct user request in a group is a required-reply turn. After a yield, the requester's completion wake must produce a visible final ("A yield owes the conversation a visible final unless private findings let the requester choose silence", `subagent-announce.requester-settle-state.ts:170-172`). The three completion-wake runs showed the same retry (`empty response detected … visible-answer continuation`). Ambient room events never reached the model. The user-request case matches `origin/main` exactly. (f) worker-placed turn: our setup has no worker environments, so ordinary turns never cross the worker surface. The worker regression above covers it. LOC vs `origin/main`: production +19/−2 (7 files), tests +36, docs +18/−5. ## Bounded cost - Runtime: one `Set` built from the request's tool list, only on Astra async-tool requests. No new requests, timers, state, settings or messages. A yield that waits for async results no longer produces a blind answer, so the incident case saves one wasted answer of about 400 output tokens. - Live proof spend: about $8.56 of `gpt-6-astra` across 20 Telegram Test Server runs. That is $3.59 for exploration and the first before/after pair, and $4.97 for the final-head siblings and the `origin/main` `NO_REPLY` baseline. Figures are summed from transcript usage costs, including sub-agents. Every run-owned forum topic has been deleted. Co-authored-by: Ayaan Zaidi <[email protected]>
Additional instructions
Keep Allow edits from maintainers enabled so maintainers can update this branch.
What Problem This Solves
Astra's Responses API can keep generating while a function runs, accept user steering during generation, and change reasoning effort without invalidating the existing prompt cache. OpenClaw's built-in runtime currently waits for the whole response before executing tools, queues steering for a later request, and changes effort at the top level of each request.
Why This Change Was Made
The Agent now persists each completed async call before admitting it through the existing tool executor, then continues consuming the model stream. Admission remains ordered while configured parallel tools overlap; sequential and deferred-tool exclusions stay with the existing executor. Terminal calls in an async response use the same scheduler. Delayed results retain their original call identity and replay correctly across response fragments and model changes. WebSocket steering reserves one queued input batch per response through acceptance and follows the server's automatic continuation without duplicating input or retrying an ambiguously dispatched request. Provider-owned input fingerprints preserve actual delivery order across saved-history recovery, replacing the duplicate socket pending-input cache. Effort updates reuse the validated prior request prefix and insert
configuration_updatebefore the next user turn.Ordinary responses finalize through the wrapped stream result and retain unchanged content identity, preserving code-mode source ownership and diagnostic hooks. Async dispatch derives calls from the finalized message after awaited hooks, so corrected arguments take effect and removed calls do not execute. Steering rejected before ID allocation releases only the matching uncommitted input for ordinary queued delivery.
This belongs to the OpenAI Platform transport and built-in OpenClaw runtime. The native Codex harness remains separate. There are no new operator settings or persistence schemas; the provider guide documents the existing runtime and transport selections. Async calls use direct function tools, and cache-preserving effort changes exclude pro mode, multi-agent mode, and automatic compaction/truncation. Tool results use normal Responses continuation;
response.steeraccepts user messages only.User Impact
Users running Astra through the built-in runtime can get useful output while tools run and steer an active WebSocket response. Changing reasoning effort between supported turns preserves the original cached prefix. Existing tool admission, lifecycle, abort handling, and transcript ownership remain authoritative.
Evidence
Authenticated live tests ran the actual Agent and Responses transport with synthetic prompts and tools. A preliminary attempt failed the single-tool-count assertion; the final rebuilt candidate passed all five scenarios:
toJSONmethod.Focused validation covers 439 tests across 21 files: 360 package tests and 79 host tests passed on the final candidate. Reproduced regressions cover admission and cancellation races, parallel/sequential scheduling, mixed tool calls, steering batch boundaries, context and payload projection, delayed-result identity, and saved-history recovery. The corresponding tests failed before their fixes. The final review found two more edge cases in finalized-call dispatch and early steering rejection: all four new regression cases failed before repair, then passed in the 49-case focused run. A tools/instructions continuation concern was disproven by the existing owner code and an extended integration test; explicit continuation already uses the new settings.
Source-ownership coverage includes 22 session cases: 16 failed on the previous PR head and now pass, including SQLite close/reopen, extension replacements, secret redaction, and stale/reentrant ownership. The diagnostics wrapper adds 13 passing cases.
The existing compaction HTTP fixture reproduced a 100 ms cold-connection race. Its body-deadline cases now advance a controlled clock after real HTTP headers, preserving the deadline and assertions without changing production timeouts.
AI and agent package builds, core and package-test typechecks, and targeted lint pass. All final changed-file gates passed, including full core/test typechecks, export scans, lint, import-cycle and runtime/store guards. Hosted CI passed on the final revision: run 33855051894. Export audits report zero unused entries. Independent Codex review covered scheduling, steering ownership, continuation, and replay; the final follow-up review is clean through P2 after the two repairs. The full build's declaration output was discarded because review edits changed the compilation snapshot; the final validation uses scoped package builds and typechecks rather than claiming a completed full declaration build.
Contract checks: async tool calling, steering, and reasoning. Personally inspected current Codex source at
1b53f6a44eff890b5169bde8d3bd5b12b8766946:codex-rs/codex-api/src/endpoint/responses_websocket.rs:230,codex-rs/core/src/session/turn.rs:2810,codex-rs/app-server/src/request_processors/turn_processor.rs:1000, andcodex-rs/protocol/src/models.rs:1200.The production delta is +1,236 lines; tests add 2,632 net lines. The growth implements the three runtime capabilities and their queue/connection lifecycle owners. The existing stream path was extracted rather than duplicated, and the compact HTTP helper was moved without changing its behavior.
The prior hosted run passed its code and test lanes but failed the production dependency audit because npm’s advisory endpoint timed out. The same timeout reproduced locally, including a one-package request. The final hosted security job passed after the endpoint recovered; the required gate remained enabled throughout.
ClawSweeper follow-up: protocol evidence and storage compatibility
The completed review found no code defects. Its external-contract proof request and rank-up move are addressed below with a fresh authenticated run on the unchanged reviewed head. Model selectors, credentials, generated text and raw IDs are omitted; opaque IDs are aliased consistently. The event fields come from outgoing SDK requests, incoming HTTP/SSE or WebSocket events, and separately marked Agent execution observations. Repeated reasoning-item completion events are omitted from this excerpt.
The async call started at 1,643 ms, generation continued at 1,649 ms while the tool was pending, and the result was delivered once on continuation. The initial response reached its output limit; the next request completed successfully. WebSocket steering received two acceptances and three server responses from one client create. Low → high → medium effort sent 0/1/2 input updates while the top-level effort stayed low; returned cache reads were 0/3,979/4,007 tokens.
Inspect redacted authenticated protocol trace — 2026-09-04 09:37 UTC
Endpoint:
https://api.openai.com/v1/responsesHead:
2025d133d6acf1b00e1fcf94151265fb5abd8227{"seq":1,"ms":18,"lane":"async-sse","direction":"sent","transport":"sse","type":"response.create","reasoning":{"effort":"medium","summary":"auto"},"tools":[{"type":"function","name":"delayed_lookup","async":true}],"input":[{"type":"message","role":"user"}]} {"seq":2,"ms":461,"lane":"async-sse","direction":"received","transport":"sse","type":"http.response","endpoint":"https://api.openai.com/v1/responses","status":200} {"seq":3,"ms":469,"lane":"async-sse","direction":"received","transport":"sse","type":"response.created","response_id":"id_1","status":"in_progress"} {"seq":4,"ms":1635,"lane":"async-sse","direction":"received","transport":"sse","type":"response.output_item.done","item":{"type":"function_call","name":"delayed_lookup","call_id":"id_2","async":true}} {"seq":5,"ms":1643,"lane":"async-sse","direction":"observed","transport":"agent","type":"tool.start","name":"delayed_lookup"} {"seq":6,"ms":1649,"lane":"async-sse","direction":"observed","transport":"agent","type":"generation.continued_while_tool_pending","event":"text_delta"} {"seq":7,"ms":1649,"lane":"async-sse","direction":"observed","transport":"agent","type":"tool.finish","name":"delayed_lookup"} {"seq":8,"ms":7463,"lane":"async-sse","direction":"received","transport":"sse","type":"response.output_item.done","item":{"type":"message","role":"assistant"}} {"seq":46,"ms":40524,"lane":"async-sse","direction":"received","transport":"sse","type":"response.incomplete","response_id":"id_1","status":"incomplete","reason":"max_output_tokens","usage":{"input_tokens":149,"cached_tokens":0,"output_tokens":2048}} {"seq":47,"ms":40539,"lane":"async-sse","direction":"sent","transport":"sse","type":"response.create","reasoning":{"effort":"medium","summary":"auto"},"tools":[{"type":"function","name":"delayed_lookup","async":true}],"input":[{"type":"message","role":"user"},{"type":"function_call","name":"delayed_lookup","call_id":"id_2","async":true},{"type":"message","role":"assistant"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"reasoning"},{"type":"function_call_output","call_id":"id_2"}]} {"seq":48,"ms":41132,"lane":"async-sse","direction":"received","transport":"sse","type":"http.response","endpoint":"https://api.openai.com/v1/responses","status":200} {"seq":49,"ms":41146,"lane":"async-sse","direction":"received","transport":"sse","type":"response.created","response_id":"id_3","status":"in_progress"} {"seq":50,"ms":42257,"lane":"async-sse","direction":"received","transport":"sse","type":"response.output_item.done","item":{"type":"message","role":"assistant"}} {"seq":51,"ms":42268,"lane":"async-sse","direction":"received","transport":"sse","type":"response.completed","response_id":"id_3","status":"completed","usage":{"input_tokens":2200,"cached_tokens":0,"output_tokens":31}} {"seq":52,"ms":42270,"lane":"async-sse","direction":"observed","transport":"agent","type":"scenario.result","passed":true,"turns":2,"toolCalls":1,"startedBeforeTerminal":true,"continuedWhileToolPending":true,"toolResults":1} {"seq":53,"ms":44294,"lane":"steering-websocket","direction":"sent","transport":"websocket","type":"response.create","reasoning":{"effort":"medium","summary":"auto"},"tools":[],"input":[{"type":"message","role":"user"}]} {"seq":54,"ms":44880,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.created","response_id":"id_4","status":"in_progress"} {"seq":55,"ms":44881,"lane":"steering-websocket","direction":"sent","transport":"websocket","type":"response.steer","previous_response_id":"id_4","input":[{"type":"message","role":"user"}]} {"seq":56,"ms":45092,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.steer.accepted","steer":{"id":"id_5","previous_response_id":"id_4"}} {"seq":57,"ms":55298,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.output_item.done","item":{"type":"message","role":"assistant"}} {"seq":58,"ms":55298,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.completed","response_id":"id_4","status":"completed","usage":{"input_tokens":49,"cached_tokens":0,"output_tokens":475}} {"seq":59,"ms":55459,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.created","response_id":"id_6","status":"in_progress"} {"seq":60,"ms":55460,"lane":"steering-websocket","direction":"sent","transport":"websocket","type":"response.steer","previous_response_id":"id_6","input":[{"type":"message","role":"user"}]} {"seq":61,"ms":55544,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.steer.accepted","steer":{"id":"id_7","previous_response_id":"id_6"}} {"seq":62,"ms":65258,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.output_item.done","item":{"type":"message","role":"assistant"}} {"seq":63,"ms":65261,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.completed","response_id":"id_6","status":"completed","usage":{"input_tokens":579,"cached_tokens":0,"output_tokens":471}} {"seq":64,"ms":65454,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.created","response_id":"id_8","status":"in_progress"} {"seq":65,"ms":75886,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.output_item.done","item":{"type":"message","role":"assistant"}} {"seq":66,"ms":75889,"lane":"steering-websocket","direction":"received","transport":"websocket","type":"response.completed","response_id":"id_8","status":"completed","usage":{"input_tokens":1104,"cached_tokens":0,"output_tokens":506}} {"seq":67,"ms":75890,"lane":"steering-websocket","direction":"observed","transport":"agent","type":"scenario.result","passed":true,"turns":3,"steerAccepted":true,"steeringBatches":2,"contextProjection":true,"payloadProjection":true,"serverResponses":3,"clientCreates":1} {"seq":68,"ms":75895,"lane":"reasoning-cache","direction":"sent","transport":"sse","type":"response.create","reasoning":{"effort":"low","summary":"auto"},"input":[{"type":"message","role":"user"}]} {"seq":69,"ms":76383,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"http.response","endpoint":"https://api.openai.com/v1/responses","status":200} {"seq":70,"ms":76387,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"response.created","response_id":"id_9","status":"in_progress"} {"seq":71,"ms":77080,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"response.output_item.done","item":{"type":"message","role":"assistant"}} {"seq":72,"ms":77125,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"response.completed","response_id":"id_9","status":"completed","usage":{"input_tokens":3982,"cached_tokens":0,"output_tokens":10}} {"seq":73,"ms":77128,"lane":"reasoning-cache","direction":"sent","transport":"sse","type":"response.create","reasoning":{"effort":"low","summary":"auto"},"input":[{"type":"message","role":"user"},{"type":"message","role":"assistant"},{"type":"configuration_update","reasoning":{"effort":"high"}},{"type":"message","role":"user"}]} {"seq":74,"ms":77548,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"http.response","endpoint":"https://api.openai.com/v1/responses","status":200} {"seq":75,"ms":77560,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"response.created","response_id":"id_10","status":"in_progress"} {"seq":76,"ms":79750,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"response.output_item.done","item":{"type":"message","role":"assistant"}} {"seq":77,"ms":79768,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"response.completed","response_id":"id_10","status":"completed","usage":{"input_tokens":4010,"cached_tokens":3979,"output_tokens":10}} {"seq":78,"ms":79771,"lane":"reasoning-cache","direction":"sent","transport":"sse","type":"response.create","reasoning":{"effort":"low","summary":"auto"},"input":[{"type":"message","role":"user"},{"type":"message","role":"assistant"},{"type":"configuration_update","reasoning":{"effort":"high"}},{"type":"message","role":"user"},{"type":"message","role":"assistant"},{"type":"configuration_update","reasoning":{"effort":"medium"}},{"type":"message","role":"user"}]} {"seq":79,"ms":80919,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"http.response","endpoint":"https://api.openai.com/v1/responses","status":200} {"seq":80,"ms":80922,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"response.created","response_id":"id_11","status":"in_progress"} {"seq":81,"ms":81868,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"response.output_item.done","item":{"type":"message","role":"assistant"}} {"seq":82,"ms":81868,"lane":"reasoning-cache","direction":"received","transport":"sse","type":"response.completed","response_id":"id_11","status":"completed","usage":{"input_tokens":4038,"cached_tokens":4007,"output_tokens":10}} {"seq":83,"ms":81870,"lane":"reasoning-cache","direction":"observed","transport":"agent","type":"scenario.result","passed":true,"requests":3,"selectedEfforts":["low","high","medium"],"topLevelEffort":"low","configurationUpdates":[0,1,2],"cacheReads":[0,3979,4007]}No storage migration is required. Steering admission is in-memory state in
packages/ai/src/transports/openai-responses-steering.ts:53. The durable additions are optional assistant replay metadata andtoolCall.async, stored in existing event JSON. The existing loose codec (src/agents/sessions/session-manager-codec.ts:32), full-event serialization (src/config/sessions/session-accessor.sqlite-transcript-store.ts:167), JSON loader (src/config/sessions/session-accessor.sqlite-read.ts:138) and context message passthrough (packages/agent-core/src/harness/session/session.ts:32) preserve them. Replay metadata is optional and applies only to the matching provider/API/model.Ten reader, store and version owner files are byte-identical to the pre-PR base. A real redaction → SQLite append → close/reopen → read → codec/context → provider and transport replay probe passed for four legacy rows and five async/steered rows: all rows and metadata preserved, correct replay order, one tool result, and no source-message mutation. This proves storage-reader compatibility; it does not claim old transports implement the new features, resume a live socket after process restart, or constitute a historical-binary boot test. Session version remains 3; agent/state database versions remain 19/15.
{ "passed": true, "base": "94268df40516d5e83bd52a0131e6f74d59ab519f", "head": "2025d133d6acf1b00e1fcf94151265fb5abd8227", "unchangedStorageOwners": 10, "checks": [ { "kind": "legacy", "sqliteRows": 4, "reopenedDatabase": true, "codecRoundTrip": true, "unknownMetadataPreserved": true, "replayOrderVerified": true, "durableBytesUnchanged": true }, { "kind": "modern", "sqliteRows": 5, "reopenedDatabase": true, "codecRoundTrip": true, "unknownMetadataPreserved": true, "replayOrderVerified": true, "durableBytesUnchanged": true } ], "gap": "Old transport feature execution and reconnecting an in-flight socket across process restart were not tested or claimed." }The external API confidence concern is resolved by the inspected authenticated trace, the official contract references above, the 439 passing focused tests and green required CI. No source changed after the reviewed and prepared head.