Skip to content

fix(agents): report deferred sessions_yield as a normal outcome - #149983

Merged
obviyus merged 1 commit into
mainfrom
fix/yield-deferred-not-error
Sep 16, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/yield-deferred-not-error

Conversation

@obviyus

@obviyus obviyus commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

When the model calls sessions_yield in the same response as an earlier async tool call whose result it has not received yet, OpenClaw defers the yield and keeps the turn active, as docs/tools/subagents/tool-reference.md describes. The tool returned that deferral as status: "error", so the result was stored with isError: true and channel progress showed Yield failed and pinned the row, although the run continued and the child work completed.

Why This Change Was Made

The deferral is an expected outcome. The tool now returns status: "deferred" with the same guidance for the model. The result classifier does not treat deferred as a failure, so the progress row stays neutral. The guard and the delivery of pending results to the next model request are unchanged. This state has one writer: the yield tool's result.

User Impact

No "Yield failed" row for a deferral. Real yield errors (no session context, no pending child completion, rejected claim) still show as failures.

Evidence

Live Telegram DM turn on the Test Server against the official OpenAI Responses endpoint with async tool calls enabled, prompt: start sleep 25 && echo YIELD_PROOF_DONE with exec and call sessions_yield in the same response. The model made two yield calls on both builds; the first is the async-result deferral, the second is a genuine "no pending child completion" error. Both builds delivered the exec output and replied YIELD_PROOF_DONE.

Progress draft rows main c4f6e6b38bf this branch
first yield (deferral) ⏸️ Yield failed (stored isError: true, status error) ⏸️ Yield (stored isError: false, status deferred)
second yield (no pending child) ⏸️ Yield failed ⏸️ Yield failed
final reply YIELD_PROOF_DONE YIELD_PROOF_DONE

Unit red on main with the tool at main and the new tests present:

node scripts/run-vitest.mjs run src/agents/tools/sessions-yield-tool.test.ts            # 1 failed | 11 passed
node scripts/run-vitest.mjs run packages/agent-core/src/agent-loop.async-yield.test.ts  # 3 failed | 1 passed

Green on this branch: 12/12, 4/4, and the two handler cases. Changed-file lint, format, max-lines and assertion-safety ratchets, and the full typecheck preflight pass.

Compatibility

No config, schema, protocol, or SDK change.

Consumers

Readers of this result's status only check "yielded"; none read the old error field.

Invalidation

None; per-call value, no cached projection.

Tests

A tool test runs the deferral inside the execution context and asserts a non-error deferred result with no claim or yield. The async-yield loop test runs with the production result classifier and asserts the persisted deferred result is not an error. A tool-handler test checks that a deferred yield result becomes a completed progress item while an error result still becomes a failed one.

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 16, 2026
@obviyus
obviyus marked this pull request as ready for review September 16, 2026 10:34
When sessions_yield runs before earlier async tool results have reached
the model, the tool defers and keeps the turn active. It returned that
deferral as status "error", so the channel progress row read
"Yield failed" although nothing failed and the run continued.

Return status "deferred" with the same guidance instead. The result
classifier no longer marks it as an error, the progress row stays
neutral, and the next model response still receives the pending results
before the model decides whether to yield again.
@obviyus
obviyus force-pushed the fix/yield-deferred-not-error branch from 82a3d53 to 2ee02da Compare September 16, 2026 10:42
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 16, 2026, 6:48 AM ET / 10:48 UTC.

ClawSweeper review

What this changes

The PR reports deferred session yielding as a normal outcome and adds coverage for transcript error flags and progress-item status.

Merge readiness

⛔ Needs changes before merge - 1 item remains

The fix remains useful: current main still classifies an expected deferral as an error. No introduced correctness or security defect was found.

Priority: P2
Reviewed head: 2ee02dae80f1feb608bef115df8eb501c89dbc62

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused producer-level correction with useful regression coverage and no identified code defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The verified maintainer author is exempt from the external-contributor runtime-proof gate. Supplied tests exercise the yield producer, loop persistence, and progress classification; they do not demonstrate rendered channel output, whose screenshot requirement remains a separate before-merge action.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified maintainer author is exempt from the external-contributor runtime-proof gate. Supplied tests exercise the yield producer, loop persistence, and progress classification; they do not demonstrate rendered channel output, whose screenshot requirement remains a separate before-merge action.
Evidence reviewed 8 items Current main still needs the correction: The fetched main revision retains status:error and an error field in the unobserved-async-results branch.
Narrow producer correction: The introduced production hunk changes only the deferral payload. Session checks, the early return, claim validation, and the actual yield callback remain intact.
Classifier and progress contract: The shared classifier recognizes error statuses and truthy error fields. The completion handler combines that classification with the execution error flag and emits completed or failed progress status; the new payload therefore removes the false failure without weakening genuine errors.
Findings None None.
Security None None.

How this fits together

The session-yield tool lets an agent pause while waiting for child work. Its result feeds the model transcript and channel progress reporting; unobserved async results require the turn to continue instead.

flowchart TD
  A[Model requests yield] --> B{Earlier results unobserved?}
  B -->|Yes| C[Return normal deferral]
  C --> D[Deliver results to next model request]
  B -->|No| E[Check yield claim]
  E --> F[Yield or report genuine error]
  C --> G[Transcript and progress status]
  F --> G
Loading

Before merge

  • Complete next step (P2) - Attach inspected, sanitized before/after screenshots showing the deferred Yield progress row in both the originating chat and the PR body or a body-linked comment, and verify that both destinations render them.
Agent review details

Security

None.

PR surface

Source 0, Tests +79. Total +79 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 3 0
Tests 3 80 1 +79
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 83 4 +79

Review metrics

None.

Technical review

Best possible solution:

Keep deferral as a non-error result at the yield tool, preserving result delivery, claim validation, and genuine failure reporting.

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

Yes, from source: call sessions_yield before earlier async results reach a subsequent model request; main returns an error payload that the shared classifier marks as failed. No runtime reproduction was executed in this review.

Is this the best way to solve the issue?

Yes. Correcting the producing tool's payload is narrower and more consistent than special-casing deferral in transcript or progress consumers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4bba1462564a.

Labels

Label changes:

  • add P2: Expected yielding deferrals misleadingly appear as failures, although the turn and child work continue.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The verified maintainer author is exempt from the external-contributor runtime-proof gate. Supplied tests exercise the yield producer, loop persistence, and progress classification; they do not demonstrate rendered channel output, whose screenshot requirement remains a separate before-merge action.
  • add proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The changed failure classification affects visible channel progress, including Telegram's Yield progress row.

Label justifications:

  • P2: Expected yielding deferrals misleadingly appear as failures, although the turn and child work continue.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The verified maintainer author is exempt from the external-contributor runtime-proof gate. Supplied tests exercise the yield producer, loop persistence, and progress classification; they do not demonstrate rendered channel output, whose screenshot requirement remains a separate before-merge action.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The changed failure classification affects visible channel progress, including Telegram's Yield progress row.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach sanitized before/after screenshots of the affected progress row in the originating chat and PR, and verify both render.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • 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.

@obviyus
obviyus merged commit e252366 into main Sep 16, 2026
336 of 339 checks passed
@obviyus
obviyus deleted the fix/yield-deferred-not-error branch September 16, 2026 12:30
@obviyus

obviyus commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

Proof: live Telegram DM on the Test Server, before and after, with a background exec and sessions_yield requested in the same model response.

  • Bug: the async-result deferral of sessions_yield came back as an error, so the progress draft showed "⏸️ Yield failed" while the run kept going and finished normally.
  • Fix: the deferral is a normal deferred result; the draft row stays "⏸️ Yield", pending results still reach the next model request, and a real yield error still shows as failed.
Before After
⏸️ Yield failed for the deferral, then YIELD_PROOF_DONE ⏸️ Yield for the deferral, then YIELD_PROOF_DONE

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…claw#149983)

## What Problem This Solves
When the model calls `sessions_yield` in the same response as an earlier async tool call whose result it has not received yet, OpenClaw defers the yield and keeps the turn active, as docs/tools/subagents/tool-reference.md describes. The tool returned that deferral as `status: "error"`, so the result was stored with `isError: true` and channel progress showed **Yield failed** and pinned the row, although the run continued and the child work completed.

## Why This Change Was Made
The deferral is an expected outcome. The tool now returns `status: "deferred"` with the same guidance for the model. The result classifier does not treat `deferred` as a failure, so the progress row stays neutral. The guard and the delivery of pending results to the next model request are unchanged. This state has one writer: the yield tool's result.

## User Impact
No "Yield failed" row for a deferral. Real yield errors (no session context, no pending child completion, rejected claim) still show as failures.

## Evidence
Live Telegram DM turn on the Test Server against the official OpenAI Responses endpoint with async tool calls enabled, prompt: start `sleep 25 && echo YIELD_PROOF_DONE` with `exec` and call `sessions_yield` in the same response. The model made two yield calls on both builds; the first is the async-result deferral, the second is a genuine "no pending child completion" error. Both builds delivered the exec output and replied `YIELD_PROOF_DONE`.

| Progress draft rows | main `e076b388fc5` | this branch |
| --- | --- | --- |
| first yield (deferral) | `⏸️ Yield failed` (stored `isError: true`, status `error`) | `⏸️ Yield` (stored `isError: false`, status `deferred`) |
| second yield (no pending child) | `⏸️ Yield failed` | `⏸️ Yield failed` |
| final reply | `YIELD_PROOF_DONE` | `YIELD_PROOF_DONE` |

Unit red on main with the tool at main and the new tests present:
```
node scripts/run-vitest.mjs run src/agents/tools/sessions-yield-tool.test.ts            # 1 failed | 11 passed
node scripts/run-vitest.mjs run packages/agent-core/src/agent-loop.async-yield.test.ts  # 3 failed | 1 passed
```
Green on this branch: 12/12, 4/4, and the two handler cases. Changed-file lint, format, max-lines and assertion-safety ratchets, and the full typecheck preflight pass.

## Compatibility
No config, schema, protocol, or SDK change.

## Consumers
Readers of this result's status only check `"yielded"`; none read the old `error` field.

## Invalidation
None; per-call value, no cached projection.

## Tests
A tool test runs the deferral inside the execution context and asserts a non-error `deferred` result with no claim or yield. The async-yield loop test runs with the production result classifier and asserts the persisted deferred result is not an error. A tool-handler test checks that a `deferred` yield result becomes a completed progress item while an `error` result still becomes a failed one.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Oct 8, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant