Repository navigation
Description
Bug type
Regression (worked before, now fails)
Beta release blocker
No
Summary
sessions_yield always returns "No session context" on MCP/claude-cli agent runtime path — gateway tool resolver missing sessionId and onYield
Steps to reproduce
- Configure agents.defaults.agentRuntime.id = "claude-cli" (default when using Claude CLI subscription billing)
- Have parent agent spawn a subagent via sessions_spawn
- Have parent agent call sessions_yield
- Observe: {"status": "error", "error": "No session context"} returned immediately
Expected behavior
sessions_yield should pause the parent session and wait for child completion, as documented and as works in the embedded runner path
Actual behavior
sessions_yield returns "No session context" on every call from the MCP/claude-cli path because sessionId and onYield are not passed by resolveGatewayScopedTools
OpenClaw version
2026.5.3-1 (2eae30e)
Operating system
macOS 15.4
Install method
npm global
Model
anthropic/claude-sonnet-4-6
Provider / routing chain
openclaw -> claude-cli -> anthropic
Additional provider/model setup details
Agent runtime: claude-cli (agents.defaults.agentRuntime.id = "claude-cli")
Auth method: OAuth via Claude CLI subscription (anthropic:claude-cli profile)
Main agent model: anthropic/claude-sonnet-4-6 (set via modelByChannel for Telegram)
Default fallback model: ollama/qwen3.5:9b (local Ollama)
Subagent model tested: ollama/qwen3.5:9b
MCP endpoint: gateway HTTP loopback at 127.0.0.1:55691/mcp
Channel: Telegram (primary)
The failure is channel-independent — occurs on any channel where agentRuntime.id = "claude-cli" is in effect.
Logs, screenshots, and evidence
## Summary
`sessions_yield` always fails with `{status: "error", error: "No session context"}` when called by an MCP client (e.g. `claude-cli` agent runtime) against the gateway's HTTP loopback MCP endpoint. The cause is in the gateway tool resolver, which builds the OpenClaw tool surface for MCP without populating the two parameters the tool requires. This is independent of channel — it surfaces wherever `agentRuntime.id = "claude-cli"` is in use, regardless of whether the originating channel is Telegram, Discord, or anything else.
The 2026.5.3-1 release notes describe a `sessions_yield` fix; that fix landed in the embedded runner path but the gateway/MCP path was not updated.
## Affected versions
Confirmed on **`OpenClaw 2026.5.3-1` (commit `2eae30e`)**. The structural shape (separate embedded vs MCP tool builders) suggests this has been latent since the MCP HTTP loopback was introduced.
## Symptom
For an agent run driven by `claude-cli` (config `agents.defaults.agentRuntime.id = "claude-cli"`):
1. Parent agent calls `mcp__openclaw__spawn` to spawn a subagent — succeeds.
2. Parent agent calls `mcp__openclaw__sessions_yield` to end its turn and wait for child completion — receives:
{"status": "error", "error": "No session context"}
3. Parent agent never re-engages with the child completion event.
Subagent spawn and the child's run/announce delivery work correctly. The failure is isolated to `sessions_yield`.
## Root cause
The gateway tool resolver does not pass `sessionId` or `onYield` through to `createOpenClawTools`.
### Tool implementation
`src/agents/tools/sessions-yield-tool.ts` (in this build: `dist/openclaw-tools-D7Zj4hDN.js:8145–8167`):
function createSessionsYieldTool(opts) {
return {
name: "sessions_yield",
execute: async (_toolCallId, args) => {
const message = readStringParam$1(args, "message") || "Turn yielded.";
if (!opts?.sessionId) return jsonResult({
status: "error",
error: "No session context" // ← always hit on the MCP path
});
if (!opts?.onYield) return jsonResult({
status: "error",
error: "Yield not supported in this context"
});
await opts.onYield(message);
return jsonResult({ status: "yielded", message });
}
};
}
Both `opts.sessionId` and `opts.onYield` must be set for the tool to function.
### Embedded runner path — wires both, works
`src/agents/pi-embedded-runner/run/attempt.ts` (`runEmbeddedAttempt`, in this build: `dist/selection-DL4MPaGt.js:6515–6552`):
sessionId: params.sessionId, // ← set
// ...
onYield: (message) => { // ← set
yieldDetected = true;
yieldMessage = message;
queueYieldInterruptForSession?.();
runAbortController.abort("sessions_yield");
abortSessionForYield?.();
}
### Gateway/MCP path — wires neither, broken
`src/gateway/tool-resolution.ts` (`resolveGatewayScopedTools`, in this build: `dist/tool-resolution-BmNDC-w0.js:34–68`):
tools: createOpenClawTools({
agentSessionKey: params.sessionKey,
agentChannel: params.messageProvider ?? void 0,
agentAccountId: params.accountId,
agentTo: params.agentTo,
agentThreadId: params.agentThreadId,
allowGatewaySubagentBinding: params.allowGatewaySubagentBinding,
allowMediaInvokeCommands: params.allowMediaInvokeCommands,
disablePluginTools: params.disablePluginTools,
senderIsOwner: params.senderIsOwner,
config: params.cfg,
workspaceDir,
pluginToolAllowlist: ...,
pluginToolDenylist: ...
// sessionId: NOT PASSED
// onYield: NOT PASSED
})
The MCP HTTP loopback handler (`src/gateway/mcp-http.loopback-runtime.ts`, in this build: `dist/mcp-http-BUaWXl8U.js:343–352`) calls `resolveGatewayScopedTools` with:
const next = resolveGatewayScopedTools({
cfg: params.cfg,
sessionKey: params.sessionKey,
messageProvider: params.messageProvider,
accountId: params.accountId,
senderIsOwner: params.senderIsOwner,
surface: "loopback",
excludeToolNames: NATIVE_TOOL_EXCLUDE
});
There is no `sessionId` in scope at the MCP-HTTP layer at all — the field is run-bound, and at MCP-tool-call time the gateway is not driving a run; `claude-cli` is.
## Why subagent spawn works but `sessions_yield` doesn't
Subagent tools key off `agentSessionKey` (passed by `resolveGatewayScopedTools`). `sessions_yield` keys off `sessionId` (not passed). Both code paths run through the same MCP loopback, but only the former has all its required inputs populated.
## Architectural note on `onYield`
A drop-in fix that just plumbs `sessionId` through is not sufficient, because the embedded `onYield` semantics don't translate to the MCP path:
runAbortController.abort("sessions_yield");
In the embedded runner the gateway owns the model loop and can abort it. In the MCP/claude-cli path the model loop runs inside `claude-cli`; the gateway has no abort handle for it. The natural turn-end for `claude-cli` is "the tool returned" — it ends its turn after receiving the tool result regardless. So the MCP-path `onYield` should:
1. Mark the parent session as paused for `sessions_yield` in the subagent registry (matches the existing `entry.pauseReason = "sessions_yield"` flag at `dist/subagent-registry-DXnKPE_6.js:849-850` and the gate at `1481`).
2. Ensure pending and future child completion events are queued for the next user turn.
3. Return success synchronously so the tool result reaches `claude-cli` and lets it end its turn naturally.
No abort, no interrupt injection, no transcript stitching needed on the gateway side — the protocol boundary makes that the client's job.
## Suggested fix direction (not prescribing a patch)
1. Plumb a session/run binding through the MCP HTTP layer. The MCP handler already has `params.sessionKey`; resolving the active run/transcript `sessionId` from that (or from the existing per-session context lookup used elsewhere) gives `createSessionsYieldTool` what it needs for the gate check.
2. Provide an MCP-flavored `onYield` that records pause-for-yield in the subagent registry rather than aborting a non-existent local controller. Keep the embedded `onYield` unchanged.
3. Keep the existing parent-channel-context fields (`agentChannel`, `agentTo`, `agentThreadId`, …) as the source of truth for child-completion delivery — those already work.
A repro is straightforward: any `agents.defaults.agentRuntime.id = "claude-cli"` setup with a parent agent that spawns at least one subagent and then calls `sessions_yield`. The error path is hit on every MCP `tools/call` for `sessions_yield`, regardless of channel.
## Side note
The file paths above use this build's hashed dist filenames (`*-BMnDC-w0.js`, `*-DL4MPaGt.js`, `*-D7Zj4hDN.js`, `*-BUaWXl8U.js`). Hashes rotate per build; the source-tree paths (`src/gateway/tool-resolution.ts`, `src/agents/tools/sessions-yield-tool.ts`, `src/agents/pi-embedded-runner/run/attempt.ts`, `src/gateway/mcp-http.loopback-runtime.ts`) and function names (`resolveGatewayScopedTools`, `createSessionsYieldTool`, `runEmbeddedAttempt`) are stable.Impact and severity
Affected: All users with agentRuntime.id = "claude-cli" (any Claude CLI subscription billing setup)
Severity: Blocks workflow — multi-agent coordination via sessions_yield is completely non-functional
Frequency: Always — 100% reproduction rate
Consequence: Subagents cannot report results back to parent agent; multi-step reasoning chains broken
Additional information
Last known good: unknown. Regression: 5.3-1 changelog claims sessions_yield fix but fix only landed in embedded runner path, not MCP/gateway path. See architectural note in evidence section for fix direction.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 4, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 14, 2026, 3:09 PM ET / 19:09 UTC.
Summary
Keep open: current
mainand v2026.6.6 still lack the MCP/CLI loopback session/yield context required bysessions_yield, and the issue is already paired with an open closing PR that has not merged.Reproducibility: yes. source-level. Current
mainconstructs gateway/MCP tools without thesessionIdandonYieldfields thatsessions_yieldrequires, so a loopback call reaches the documentedNo session contexterror path.Next step
Do not queue a separate ClawSweeper repair job while an open closing PR already targets this issue.
Review details
Best possible solution:
Refresh, review, and land #90861 or an equivalent narrow fix that threads run session/yield context through the MCP loopback path and preserves yielded lifecycle state.
Do we have a high-confidence way to reproduce the issue?
Yes, source-level. Current
mainconstructs gateway/MCP tools without thesessionIdandonYieldfields thatsessions_yieldrequires, so a loopback call reaches the documentedNo session contexterror path.Is this the best way to solve the issue?
Yes, the remaining fix direction is clear: update the gateway/MCP loopback context plumbing and lifecycle handling, preferably by landing the open linked PR after conflicts and maintainer review. Creating a separate automated fix PR now would duplicate that open implementation path.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against a189baa4b344.
Label changes
Label changes:
clawsweeper:no-new-fix-pr: Current issue advisory state no longer selects this label.clawsweeper:linked-pr-open: Current issue advisory state no longer selects this label.Label justifications:
P1: The report describes a broken CLI-backed multi-agentsessions_yieldworkflow that blocks affected users from pausing and resuming parent sessions after subagent work.impact:session-state: The failure is caused by missing run session context and prevents yielded parent-session state from being recorded on the MCP/CLI path.Evidence reviewed
What I checked:
AGENTS.md:1, a189baa4b344)sessions_yieldreturnsNo session contextwhen constructed withoutsessionId, and separately requiresonYieldbefore it can returnyielded. (src/agents/tools/sessions-yield-tool.ts:27, a189baa4b344)resolveGatewayScopedToolscallscreateOpenClawToolswithoutsessionIdoronYield, so loopback-scoped tools cannot satisfy thesessions_yieldcontract. (src/gateway/tool-resolution.ts:159, a189baa4b344)sessionIdfield to forward into gateway tool resolution. (src/gateway/mcp-http.request.ts:356, a189baa4b344)x-openclaw-session-idheader for a CLI MCP client to echo back. (src/gateway/mcp-http.loopback-runtime.ts:42, a189baa4b344)onYieldcallback that marks yield detection and aborts the local model loop, confirming the reported missing sibling behavior is specific to the gateway/MCP path. (src/agents/embedded-agent-runner/run/attempt.ts:1312, a189baa4b344)Likely related people:
sessions_yieldfeature PR that added the tool contract and embedded-runner yield behavior this issue compares against. (role: introduced behavior context; confidence: high; commits: 3fa91cd69d5d; files:src/agents/tools/sessions-yield-tool.ts,src/agents/openclaw-tools.ts,src/agents/embedded-agent-runner/run/attempt.ts)sessions_yieldPR and authored commits in that PR tightening yield timing and payload-hook behavior. (role: merger and adjacent contributor; confidence: high; commits: 3fa91cd69d5d, 05512341176d, 9903cc87c0b2; files:src/agents/embedded-agent-runner/run/attempt.ts,src/agents/tools/sessions-yield-tool.ts)src/agents/subagent-announce.ts,src/agents/subagent-registry-run-manager.ts,src/utils/delivery-context.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.openclaw-barnacle commentedon May 31, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
vincentkoc commentedon Jun 16, 2026
Fixed on
mainby PR #90861.Landed as five preserved commits (rebase merge, no squash), ending at
2b05bd7b0d9a10ab6b0e3d78433263520efd4afd. The fix routes CLI-backed MCPsessions_yieldthrough the existing generation-bound capture owner, propagates paused/end-turn metadata, and avoids stale cached yield callbacks.Proof: production loopback HTTP call returned HTTP 200 with
status: yielded; 372 focused tests passed; AWS Crabboxcheck:changed, exact-head CI/security/CodeQL, and final autoreview all passed.