Commit 89db7a0
committed
fix(agents,gateway): three subagent announce delivery failures
Fixes three related bugs that break subagent completion delivery in
loopback token-auth setups (e.g. Google Chat with sessions_spawn).
All three were found and validated on a production Linux/GCP deployment
(openclaw 2026.5.20, Node 22, systemd user service).
---
## Fix 1 — gateway: keep device identity for BACKEND calls with explicit scopes
File: src/gateway/call.ts
Fixes: #77807
`shouldOmitDeviceIdentityForGatewayCall` unconditionally omitted device
identity for all BACKEND + GATEWAY_CLIENT + loopback calls. Internal
calls such as `callSubagentGateway` carry explicit operator scopes like
`["operator.write"]`. Without device identity the gateway cannot verify
those scopes against the paired device token and rejects with:
Subagent completion direct announce failed: missing scope: operator.write
Fix: return false (keep device identity) when `params.scopes` is
non-empty. Also threads `scopes` through `resolveDeviceIdentityForGatewayCall`
so the helper can inspect them.
---
## Fix 2 — sessions_yield: await settle promise after timeout
File: src/agents/pi-embedded-runner/run/attempt.sessions-yield.ts
`waitForSessionsYieldAbortSettle` raced the settle promise against a
2 s timeout and returned immediately on timeout, leaving the session
transcript file lock held. The next turn on the same persistent session
(e.g. a Google Chat DM) then failed with "file lock stale", triggering
a model fallback and surfacing an internal error message to end users.
Fix: after logging the timeout warning, await `settlePromise.catch(() => {})`
so the file lock is always released before the function returns.
---
## Fix 3 — sessions_yield: strip context message before completion announce
File: src/agents/pi-embedded-runner/run/attempt.sessions-yield.ts
When a new incoming message aborts an active `sessions_yield`, the
`openclaw.sessions_yield` context message (containing "[Context: The
previous turn ended intentionally via sessions_yield...]") remains in
the session transcript. When a subagent completion announce subsequently
re-runs the agent to deliver the result, the agent sees this context
message and responds via `sessions_yield` again (a `custom_message`).
The announce system does not recognise a `custom_message` as a visible
reply and emits:
Subagent announce give up: completion agent did not produce a visible reply
`stripSessionsYieldArtifacts` already strips the interrupt custom type
(`openclaw.sessions_yield_interrupt`) but not the context custom type
(`openclaw.sessions_yield`). Fix: strip both types in the in-memory
messages loop and in the fileEntries loop.
---
Tested on production (Google Chat + Pipedrive sub-agent workflow):
- Single sub-agent turn: delivers correctly
- Two rapid consecutive messages (second arrives while sub-agent runs):
both deliver, no fallback, no stale lock, no scope errors
Reported-by: jailbirt <jailbirt@theeye.io>1 parent 33df3be commit 89db7a0
2 files changed
Lines changed: 34 additions & 2 deletions
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
167 | 172 | | |
168 | 173 | | |
169 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
170 | 189 | | |
171 | 190 | | |
172 | 191 | | |
| |||
205 | 224 | | |
206 | 225 | | |
207 | 226 | | |
208 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
209 | 230 | | |
210 | 231 | | |
211 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| 331 | + | |
331 | 332 | | |
332 | 333 | | |
333 | 334 | | |
334 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
335 | 345 | | |
336 | 346 | | |
337 | 347 | | |
| |||
345 | 355 | | |
346 | 356 | | |
347 | 357 | | |
| 358 | + | |
348 | 359 | | |
349 | 360 | | |
350 | 361 | | |
| |||
773 | 784 | | |
774 | 785 | | |
775 | 786 | | |
776 | | - | |
| 787 | + | |
777 | 788 | | |
778 | 789 | | |
779 | 790 | | |
| |||
0 commit comments