Skip to content

refactor(automations): retire heartbeat SDK and scheduling entry points - #180106

Merged
steipete merged 5 commits into
mainfrom
steipete/automations-s4b
Oct 22, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/automations-s4b

Conversation

@steipete

@steipete steipete commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Removes the legacy heartbeat SDK and scheduling entry points now that periodic jobs and plugin producers use ordinary Automations and session events.

User Impact

Plugin authors must replace the removed heartbeat exports and runtime methods using the migration guide. This is the breaking SDK removal Peter approved for #167796 on October 3/12. Existing configurations retain the Doctor migration and once-only notice landed in #179387. Migrated jobs and node notices use the session controller's admission and settlement boundaries.

Why This Change Was Made

S4b follows #180079 in the replacement stack for #179526 and #167796. S1 #178650, S2 #178764, and S3 #179387 (replacing #178990) are already merged. S4c next removes the unreachable executor/outcome store and directly coupled tool implementation; S4d removes the remaining internal turn flags and wake helpers.

This slice removes Gateway heartbeat startup/reload wiring and the private Cron heartbeat payload, with their directly coupled fixtures. Gateway shutdown still joins delivery recovery and upstream monitoring. Node notices retain captured destinations and current-owner checks. Doctor alone owns the legacy schedule/identity decoding. Public wake-policy vocabulary remains supported through ordinary session events.

The removed one-shot retry branch only handled the retired runner's disabled result. Its replacement regression proves that an explicitly empty scratch is skipped once and stays consumed across restart, while migrated-task proof verifies ok is recorded only after ordinary execution settles.

The typed consumer closure requires 228 paths, mostly one-line removals; executable source is net −479 lines, tests/support net −932, and docs/metadata net +10. No new configuration or lifecycle owner is introduced.

Evidence

The prepared slice passed focused SDK/runtime, node-event, Cron, Gateway, Doctor, and adapter tests, including 378 Gateway cases and 57 Doctor cases. Fresh-main integration preserves the new Cron stream sandbox target and regenerates SDK exports, the database-worker inventory, and shrink-only test baselines through their owners.

Fresh final proof: pnpm build passed; 130 focused tests plus 63 node-event cases after the mechanical extraction passed; core, Gateway, Cron, and SDK type graphs, typed lint, formatting, line-cap ratchet, and owner generators passed. pnpm plugin-sdk:api:diff passed against the frozen candidate (digest 5f4a4578): 9 named heartbeat exports removed, 36 reachable declaration changes, 215 affected exports. The later notification-handler extraction changes no SDK shape. Full-slice and extraction-delta Codex reviews are scoped-clean through P2. Exact-head CI will be recorded before landing. Live external-provider campaigns are not repeated for this removal slice; ordinary admission/settlement and restart behavior are covered at their owning boundaries.

The first CI run exposed eight stale Cron fixture fields and tests that still invoked the retired heartbeat executor. Those fixtures now use the current contract; the obsolete runner tests are replaced by 13 ordinary background-exec custody cases. The formatter now admits ordinary exec completion notices while leaving controller-owned events with their owner.

A review also caught an inline-result race in node exec completion: target capture could yield before the registry installed its notice hold. Authorization now installs that hold before capture; target/currentness checks and deduplication still precede enqueue. The owning-boundary regression failed before the repair and passes afterward. Repair proof: 94 fixture tests, 33 exec/restart/formatter cases, 64 node-event cases, and 4 restart/migrated-task cases passed, along with the five failing type graphs, both Gateway graphs, scoped lint/format, and changed-file line-cap checks.

The Feishu response-size cancellation assertions from the first CI attempt passed once on both its clean main revision and candidate with matching Node/Bun pins. This is local nonreproduction of a timing-sensitive fixture assertion, not an inherited-failure or fix claim; exact-head CI determines whether further investigation is needed.

A second CI repair preserves occurrence custody: the default formatter reads only deliverable system events, so it cannot consume an occurrence held by a different delivery owner. Explicit owner selections still work. The unchanged held-occurrence regression failed before this repair; 65 system-event/ordinary-exec cases plus 5 admission/restart cases now pass. Core/infra type graphs, scoped lint/format, and line-cap checks pass; the repair review is scoped-clean through P2.

The later Feishu card-create cancellation and Anthropic diagnostic-drainage assertions also passed once on their exact clean-main and candidate revisions with matching Node/Bun pins. They remain timing-sensitive CI failures not reproduced locally, not proven inherited or fixed. Final-head CI is authoritative.

The exact Feishu job was also replayed on secretless Linux against the actual CI main revision and this candidate, with the same Node/Bun/pnpm pins and worker settings. Both passed all 67 files / 838 cases, including all 625 Feishu cases and the two failed cancellation assertions. The lease had more CPU/RAM than CI, so this is nonreproduction on Linux, not an inherited-failure or fix claim. The single targeted retry passed. Exact-head CI run 39707406420 attempt 2 completed successfully (162 successful, 20 skipped, no failing or non-terminal jobs); native landing merged this slice as e897d98.

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T01:54:12.023598Z d5a39e8 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: codex plugin: file-transfer extensions: xai size: XL labels Oct 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2ae0784e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/gateway/server-node-events.ts Resolved
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Oct 22, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The branch and migration notes are current at 63f7c3c. The inline exec-result race is fixed with a red/green NodeRegistry regression; stale Cron fixtures and executor-only tests are migrated to the ordinary owners. Focused proof and the fresh P2 review pass. Exact-head CI is running.

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 22, 2026
@steipete
steipete enabled auto-merge (squash) October 22, 2026 01:39
@steipete
steipete disabled auto-merge October 22, 2026 01:40
@clawsweeper

clawsweeper Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR removes heartbeat SDK and scheduling entry points and routes remaining node notices through ordinary session events.

Example: A migrated inbox task runs every 30 minutes.

  • Before: Its heartbeat-task identity selects the legacy heartbeat executor.
  • After: The ordinary session controller executes the task and settles it before Cron records success.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The approved cutover has a coherent implementation, but required authority evidence is absent and exact-head CI confirms unmigrated formatter tests.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Partial
User problem: Periodic monitoring and immediate follow-ups retain heartbeat-specific entry points after replacement owners have landed.
Reason: The maintainer-approved S4b slice removes obsolete ownership and documents the accepted breaking SDK change; executor and remaining internal-contract removal are explicitly assigned to later slices.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: this maintainer-approved retirement remains necessary, but the formatter change leaves three confirmed consumer-test failures.

Priority: P2
Reviewed head: 63f7c3c4688a1edd7cab3474d7f0960a67de4896

Before merge

  • Add real behavior proof - Authority-chain proof required: exercise an authorized node notice through actual session admission and delivery, reject an unmatched node, and prove revocation during preparation and session replacement while queued prevent unauthorized effects. The NodeRegistry ordering regression is useful, but downstream handoff is mocked; inspected screenshots cover earlier editor behavior. Latest-stable upgrade preservation after removal of legacy runtime payload handling is also unestablished. Supply redacted logs or terminal output without keys, IPs, phone numbers, or non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Migrate the remaining system-event formatter tests (P2) - Removing the exec-event exclusion changes drainFormattedSystemEvents, but src/infra/system-events.test.ts still expects unclaimed exec notices to remain queued and retains a legacy delivery-held exec fixture. Exact-head job 119587325154 fails three cases at lines 112 and 544 for this reason. Update these consumers to verify that ordinary unclaimed exec notices enter the prompt once, retain the claimed-turn exclusion assertions, and retire or migrate the heartbeat-only hold fixture.
  • Resolve security concern: Establish rejection through the real node handoff - The added negative cases mock target capture and enqueueSessionEventForHost, so they stop before ordinary admission, model execution, and delivery; no reachable bypass is established by this review.
  • Resolve merge risk - Before merge, establish that an unmatched or revoked node cannot turn the new session-event handoff into model execution or outbound delivery, including revocation during preparation and target replacement while queued.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Migrate the remaining system-event formatter tests — src/auto-reply/reply/session-system-events.ts:101-102
  • [medium] Establish rejection through the real node handoff — src/gateway/server-node-events-notifications.ts:128

Tests

  • Missing end-to-end proof: Supply node-event final-effect authority coverage and a v2026.10.5 upgrade through Doctor and Gateway startup with schedules, history, scratch, and settings preserved.
Agent review details

How this fits together

Cron schedules persisted jobs, while node producers submit immediate notices; both hand execution and delivery to the existing session controller.

flowchart LR
  A[Legacy configuration] --> B[Doctor migration]
  B --> C[Automation jobs]
  C --> D[Cron scheduler]
  D --> F[Session controller]
  E[Node notices] --> F
  F --> G[Conversation delivery]
Loading

Technical review

Best possible solution:

Complete the approved retirement using the existing session controller, migrate the formatter’s remaining consumer tests, and retain Doctor as the sole legacy decoder.

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

Exact-head CI reproduces three formatter consumer-test failures, and source inspection directly connects them to removal of the exec-event exclusion; no target code was run during this review.

Is this the best way to solve the issue?

The existing session controller is the appropriate replacement owner, and the schedule and identity helpers move to Doctor without introducing another scheduler or state owner.

Full review comments:

  • [P2] Migrate the remaining system-event formatter tests — src/auto-reply/reply/session-system-events.ts:101-102
    Removing the exec-event exclusion changes drainFormattedSystemEvents, but src/infra/system-events.test.ts still expects unclaimed exec notices to remain queued and retains a legacy delivery-held exec fixture. Exact-head job 119587325154 fails three cases at lines 112 and 544 for this reason. Update these consumers to verify that ordinary unclaimed exec notices enter the prompt once, retain the claimed-turn exclusion assertions, and retire or migrate the heartbeat-only hold fixture.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0ae30072d1ca.

Merge-risk options

Maintainer options:

  1. Prove the node authority handoff (recommended)
    Exercise allowed and unmatched node events through the real handoff, then revoke the connection during preparation and replace the captured session while queued; record rejection before model execution or transport I/O.
  2. Hold the removal slice
    Keep this PR open until the node handoff’s final-effect authority evidence is available.

Provenance checked

  • Plugin runtime heartbeat entry points keeps the original intent (c538e28: The merged predecessor added session-event replacements while explicitly retaining heartbeat surfaces for the following removal slice.)
  • Inline node completion notice custody keeps the original intent (8a98a26: Hold the completion notice while the caller awaits an inline result, dropping the notice after successful inline delivery and retaining late-result recovery.)
  • Inactive Codex heartbeat fallback changes intended behavior with a stated reason (3775359: fix(codex): ignore stale heartbeat calls on normal turns #148547 prevents stale thread-catalog heartbeat calls from producing misleading unavailable-tool errors on ordinary turns.)
  • Doctor schedule and task identity helpers keeps the original intent (ec5d369: The migration retains deterministic anchors and task identities while converting legacy heartbeat state into ordinary jobs; this PR relocates those helpers to the migration owner.)

Testing

Proof path: in-process harness.

Security

Needs attention: The node handoff retains source checks, but final-effect authority coverage is not established.

Evidence

Security concerns:

  • [medium] Establish rejection through the real node handoff — src/gateway/server-node-events-notifications.ts:128
    The added negative cases mock target capture and enqueueSessionEventForHost, so they stop before ordinary admission, model execution, and delivery; no reachable bypass is established by this review.
    Confidence: 0.96

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c538e28 adds src/plugins/runtime/runtime-system.ts:32 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c538e280e808; files: src/plugins/runtime/runtime-system.ts)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Root-cause cluster

Relationship: partial_overlap
Canonical: #134994
Summary: This PR is the SDK and scheduling removal slice of the accepted heartbeat-retirement program.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P2: This is an approved architectural cleanup with a focused, confirmed validation defect.
  • add merge-risk: 🚨 compatibility: Public heartbeat SDK methods and exports are intentionally removed under the recorded maintainer-approved breaking cutover.
  • add merge-risk: 🚨 security-boundary: Node-origin authority now crosses asynchronous session admission and delivery boundaries without supplied final-effect negative proof.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is an approved architectural cleanup with a focused, confirmed validation defect.
  • merge-risk: 🚨 compatibility: Public heartbeat SDK methods and exports are intentionally removed under the recorded maintainer-approved breaking cutover.
  • merge-risk: 🚨 security-boundary: Node-origin authority now crosses asynchronous session admission and delivery boundaries without supplied final-effect negative proof.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add final-effect proof for authorized node events, unmatched-node rejection, revocation during preparation, and captured-session replacement before model or transport I/O.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 21, 2026, 9:41 PM ET / October 22, 2026, 01:41 UTC.

@steipete
steipete merged commit e897d98 into main Oct 22, 2026
448 of 452 checks passed
@steipete
steipete deleted the steipete/automations-s4b branch October 22, 2026 02:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
…ts (openclaw#180106)

* refactor(automations): retire heartbeat SDK and scheduling entry points

* docs: refresh worker inventory after main integration

* fix(automations): preserve ordinary exec completion custody

* fix(automations): retain delivery-held event custody
roboclaw-bot pushed a commit that referenced this pull request Nov 5, 2026
… SDK export (#192760)

Core no longer exports HEARTBEAT_RESPONSE_TOOL_NAME from plugin-sdk/agent-harness-runtime
(#180106), but @openclaw/codex 2026.9.7 to 2026.10.10 still import it, so a left-behind
runtime passed the 2026.9.7 floor and failed every Codex turn with a SyntaxError. Raise the
floor to 2026.11.5-beta.1, the first runtime without the import, so admission refuses it
with update repair guidance instead.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
… SDK export (openclaw#192760)

Core no longer exports HEARTBEAT_RESPONSE_TOOL_NAME from plugin-sdk/agent-harness-runtime
(openclaw#180106), but @openclaw/codex 2026.9.7 to 2026.10.10 still import it, so a left-behind
runtime passed the 2026.9.7 floor and failed every Codex turn with a SyntaxError. Raise the
floor to 2026.11.5-beta.1, the first runtime without the import, so admission refuses it
with update repair guidance instead.
obviyus added a commit that referenced this pull request Nov 17, 2026
…paid model (#200741)

Root cause: src/gateway/server-node-events-notifications.ts:128 admits phone notifications through `enqueueSessionEventForHost` without the producer's `replyExpectation: "optional"`, so in a WebChat session the `internal_system` turn resolves as result-required (src/agents/reply-completion.ts:116-122) and the CLI runner rejects an authored `NO_REPLY` as `empty_response`, which starts model fallback.

Fixes #200710

Thanks @dawidkulpa for the report with exact before/after counts, and @vaibhav375 for the fix.

## What Problem This Solves

Since 2026.11.5, when an agent decides a forwarded phone notification needs no answer and replies `NO_REPLY`, the turn fails with "CLI backend returned an empty response." and OpenClaw retries it on the fallback model. With a subscription CLI backend and an API-billed fallback, every ignored notification becomes a paid request and an "Unable to finish this reply" card in WebChat.

## User Impact

User impact: agents can ignore phone notifications again. A `NO_REPLY` answer ends the turn silently, with no error card and no fallback model call. Notifications the agent does answer still get their reply.

## Why This Change Was Made

#180106 (e897d98) moved notifications from heartbeat wakes, which allowed silence, onto ordinary host session events, without carrying over that permission. The notification producer now passes `replyExpectation: "optional"`, the same producer-owned waiver cron notifications and session-state notices already pass. Input provenance alone still grants no silence, so other `internal_system` turns keep their result requirement.

The branch keeps the contributor's fix commit. The in-process Gateway test and the docs note are folded into one assertion in the existing notification routing case, which fails on `main` and passes here.

## Evidence

Isolated source Gateway (`ocx src`), loopback, throwaway state. The agent's primary and fallback models are a scripted local CLI backend that logs every call. A WebChat client sends `chat.send` to `agent:main:main`, then a paired `openclaw-android` node sends `notifications.changed` for a promo (model answers `NO_REPLY`) and for a bank alert (model answers with text, the control).

```
main 93d8403
  promo-1: model calls=2  primary -> NO_REPLY, fallback -> "fallback answer for promo-1"
  cli terminal failure: provider=scripted-cli model=primary ... error=CLI backend returned an empty response.
  model fallback decision: decision=candidate_failed ... reason=empty_response next=scripted-cli/fallback
  urgent-1 (control): model calls=1, reply delivered
this PR
  promo-1: model calls=1  primary -> NO_REPLY; no assistant message, 0 empty_response lines, 0 fallback decisions
  urgent-1 (control): model calls=1, reply delivered
```

Regression test: `src/gateway/server-node-events.test.ts` passes 52/52 here; on `main` the two notification routing cases fail on the missing `replyExpectation: "optional"`.

<details>
<summary>Contributor live run with the real claude-cli backend (redacted; Gateway lines in IST, client lines in UTC)</summary>

```
### AFTER (this PR)
[2026-11-17T20:59:06.734Z] phone -> node.event notifications.changed {"change":"posted","key":"proof-1794949146731","packageName":"com.example.shop","title":"Weekend sale","text":"20% off everything this weekend"}
[2026-11-17T20:59:29.741Z] gateway accepted node.event: {"ok":true}
[claude stream] text_delta "text":"NO_REPLY"
2026-11-18T02:29:53.981+05:30 [agent/cli-backend] cli turn: provider=claude-cli model=claude-haiku-4-5 durationMs=9600 outBytes=8 outHash=b07800ad4773
[2026-11-17T20:59:05.295Z] webchat watching for 150s
[2026-11-17T20:59:33.317Z] webchat sees agent {"sessionKey":"agent:main:main","state":"start","stream":"lifecycle"}
[2026-11-17T20:59:45.663Z] webchat sees agent {"sessionKey":"agent:main:main","state":"starting_model","stream":"run_status"}
[2026-11-17T20:59:52.985Z] webchat sees agent {"sessionKey":"agent:main:main","stream":"thinking"}
[2026-11-17T20:59:55.153Z] webchat sees agent {"sessionKey":"agent:main:main","state":"model","stream":"lifecycle"}
[2026-11-17T20:59:55.162Z] webchat sees agent {"sessionKey":"agent:main:main","state":"end","stream":"lifecycle"}
[2026-11-17T20:59:55.165Z] webchat sees chat {"sessionKey":"agent:main:main","state":"final"}

### BEFORE (main)
[2026-11-17T21:20:11.996Z] phone -> node.event notifications.changed {"change":"posted","key":"proof-1794950411995","packageName":"com.example.shop","title":"Weekend sale","text":"20% off everything this weekend"}
[2026-11-17T21:20:21.484Z] gateway accepted node.event: {"ok":true}
2026-11-18T02:50:33.766+05:30 [agent/cli-backend] cli live session start: provider=claude-cli model=claude-haiku-4-5 activeSessions=1
[claude stream] text_delta "text":"NO_REPLY"
2026-11-18T02:50:42.818+05:30 [agent/cli-backend] cli turn: provider=claude-cli model=claude-haiku-4-5 durationMs=9391 outBytes=8 outHash=b07800ad4773
2026-11-18T02:50:42.845+05:30 [agent/cli-backend] cli empty response diagnostics: backend=claude-cli reason=exit exitCode=0 exitSignal=null durationMs=9158 stdoutBytes=19295 stdoutHash=01933c6de95a stderrBytes=0 stderrHash=e3b0c44298fc useResume=false
2026-11-18T02:50:42.854+05:30 [agent/cli-backend] cli terminal failure: provider=claude-cli model=claude-haiku-4-5 durationMs=19303 runId=<id> error=CLI backend returned an empty response.
2026-11-18T02:50:44.443+05:30 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=anthropic/claude-haiku-4-5 candidate=anthropic/claude-haiku-4-5 reason=empty_response next=openai/gpt-5.4
2026-11-18T02:51:02.161+05:30 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=anthropic/claude-haiku-4-5 candidate=openai/gpt-5.4 reason=model_not_found next=none
2026-11-18T02:51:02.198+05:30 Embedded agent failed before reply: All models failed (2): anthropic/claude-haiku-4-5: CLI backend returned an empty response. (empty_response) | openai/gpt-5.4: Unknown model: openai/gpt-5.4. GPT-5.4 has retired from the ChatGPT-account Codex route. Run `openclaw doctor --fix` to replace it with gp
2026-11-18T02:51:03.236+05:30 [gateway] notification event not delivered node=<node-id>: failed
[2026-11-17T21:20:06.510Z] webchat watching for 150s
[2026-11-17T21:20:23.374Z] webchat sees agent {"sessionKey":"agent:main:main","state":"start","stream":"lifecycle"}
[2026-11-17T21:20:33.822Z] webchat sees agent {"sessionKey":"agent:main:main","state":"starting_model","stream":"run_status"}
[2026-11-17T21:20:42.640Z] webchat sees agent {"sessionKey":"agent:main:main","stream":"thinking"}
[2026-11-17T21:20:44.529Z] webchat sees agent {"sessionKey":"agent:main:main","state":"model","stream":"lifecycle"}
[2026-11-17T21:20:44.533Z] webchat sees agent {"sessionKey":"agent:main:main","state":"fallback_step","stream":"lifecycle"}
[2026-11-17T21:21:02.019Z] webchat sees agent {"sessionKey":"agent:main:main","state":"preparing_workspace","stream":"run_status"}
[2026-11-17T21:21:02.275Z] webchat sees agent {"sessionKey":"agent:main:main","state":"preparing_context","stream":"run_status"}
[2026-11-17T21:21:02.275Z] webchat sees agent {"sessionKey":"agent:main:main","state":"model","stream":"lifecycle"}
[2026-11-17T21:21:02.277Z] webchat sees agent {"sessionKey":"agent:main:main","state":"fallback_step","stream":"lifecycle"}
[2026-11-17T21:21:02.295Z] webchat sees agent {"sessionKey":"agent:main:main","state":"error","stream":"lifecycle"}
[2026-11-17T21:21:03.162Z] webchat sees chat {"sessionKey":"agent:main:main","state":"error","error":"All models failed (2): anthropic/claude-haiku-4-5: CLI backend returned an empty response. (empty_response) | openai/gpt-5.4: Unknown model: openai/gpt-5.4. GPT-5.4 has retired from the ChatGPT-account Codex route. Run `openclaw doctor --fi..."}
```

Node IDs, run IDs and local paths are redacted. All traffic is on 127.0.0.1. The extra `claude-haiku-5-5` CLI turn after each run is OpenClaw's utility session recap, not a retry.

</details>

Merge danger: two-way door. One field on one producer, no stored state or contract change; a revert restores the 2026.11.5 behavior. Blast radius: forwarded device notifications only.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
…paid model (openclaw#200741)

Root cause: src/gateway/server-node-events-notifications.ts:128 admits phone notifications through `enqueueSessionEventForHost` without the producer's `replyExpectation: "optional"`, so in a WebChat session the `internal_system` turn resolves as result-required (src/agents/reply-completion.ts:116-122) and the CLI runner rejects an authored `NO_REPLY` as `empty_response`, which starts model fallback.

Fixes openclaw#200710

Thanks @dawidkulpa for the report with exact before/after counts, and @vaibhav375 for the fix.

## What Problem This Solves

Since 2026.11.5, when an agent decides a forwarded phone notification needs no answer and replies `NO_REPLY`, the turn fails with "CLI backend returned an empty response." and OpenClaw retries it on the fallback model. With a subscription CLI backend and an API-billed fallback, every ignored notification becomes a paid request and an "Unable to finish this reply" card in WebChat.

## User Impact

User impact: agents can ignore phone notifications again. A `NO_REPLY` answer ends the turn silently, with no error card and no fallback model call. Notifications the agent does answer still get their reply.

## Why This Change Was Made

openclaw#180106 (a67f6bd) moved notifications from heartbeat wakes, which allowed silence, onto ordinary host session events, without carrying over that permission. The notification producer now passes `replyExpectation: "optional"`, the same producer-owned waiver cron notifications and session-state notices already pass. Input provenance alone still grants no silence, so other `internal_system` turns keep their result requirement.

The branch keeps the contributor's fix commit. The in-process Gateway test and the docs note are folded into one assertion in the existing notification routing case, which fails on `main` and passes here.

## Evidence

Isolated source Gateway (`ocx src`), loopback, throwaway state. The agent's primary and fallback models are a scripted local CLI backend that logs every call. A WebChat client sends `chat.send` to `agent:main:main`, then a paired `openclaw-android` node sends `notifications.changed` for a promo (model answers `NO_REPLY`) and for a bank alert (model answers with text, the control).

```
main 7bd8ea3
  promo-1: model calls=2  primary -> NO_REPLY, fallback -> "fallback answer for promo-1"
  cli terminal failure: provider=scripted-cli model=primary ... error=CLI backend returned an empty response.
  model fallback decision: decision=candidate_failed ... reason=empty_response next=scripted-cli/fallback
  urgent-1 (control): model calls=1, reply delivered
this PR
  promo-1: model calls=1  primary -> NO_REPLY; no assistant message, 0 empty_response lines, 0 fallback decisions
  urgent-1 (control): model calls=1, reply delivered
```

Regression test: `src/gateway/server-node-events.test.ts` passes 52/52 here; on `main` the two notification routing cases fail on the missing `replyExpectation: "optional"`.

<details>
<summary>Contributor live run with the real claude-cli backend (redacted; Gateway lines in IST, client lines in UTC)</summary>

```
### AFTER (this PR)
[2026-11-17T20:59:06.734Z] phone -> node.event notifications.changed {"change":"posted","key":"proof-1794949146731","packageName":"com.example.shop","title":"Weekend sale","text":"20% off everything this weekend"}
[2026-11-17T20:59:29.741Z] gateway accepted node.event: {"ok":true}
[claude stream] text_delta "text":"NO_REPLY"
2026-11-18T02:29:53.981+05:30 [agent/cli-backend] cli turn: provider=claude-cli model=claude-haiku-4-5 durationMs=9600 outBytes=8 outHash=b07800ad4773
[2026-11-17T20:59:05.295Z] webchat watching for 150s
[2026-11-17T20:59:33.317Z] webchat sees agent {"sessionKey":"agent:main:main","state":"start","stream":"lifecycle"}
[2026-11-17T20:59:45.663Z] webchat sees agent {"sessionKey":"agent:main:main","state":"starting_model","stream":"run_status"}
[2026-11-17T20:59:52.985Z] webchat sees agent {"sessionKey":"agent:main:main","stream":"thinking"}
[2026-11-17T20:59:55.153Z] webchat sees agent {"sessionKey":"agent:main:main","state":"model","stream":"lifecycle"}
[2026-11-17T20:59:55.162Z] webchat sees agent {"sessionKey":"agent:main:main","state":"end","stream":"lifecycle"}
[2026-11-17T20:59:55.165Z] webchat sees chat {"sessionKey":"agent:main:main","state":"final"}

### BEFORE (main)
[2026-11-17T21:20:11.996Z] phone -> node.event notifications.changed {"change":"posted","key":"proof-1794950411995","packageName":"com.example.shop","title":"Weekend sale","text":"20% off everything this weekend"}
[2026-11-17T21:20:21.484Z] gateway accepted node.event: {"ok":true}
2026-11-18T02:50:33.766+05:30 [agent/cli-backend] cli live session start: provider=claude-cli model=claude-haiku-4-5 activeSessions=1
[claude stream] text_delta "text":"NO_REPLY"
2026-11-18T02:50:42.818+05:30 [agent/cli-backend] cli turn: provider=claude-cli model=claude-haiku-4-5 durationMs=9391 outBytes=8 outHash=b07800ad4773
2026-11-18T02:50:42.845+05:30 [agent/cli-backend] cli empty response diagnostics: backend=claude-cli reason=exit exitCode=0 exitSignal=null durationMs=9158 stdoutBytes=19295 stdoutHash=01933c6de95a stderrBytes=0 stderrHash=e3b0c44298fc useResume=false
2026-11-18T02:50:42.854+05:30 [agent/cli-backend] cli terminal failure: provider=claude-cli model=claude-haiku-4-5 durationMs=19303 runId=<id> error=CLI backend returned an empty response.
2026-11-18T02:50:44.443+05:30 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=anthropic/claude-haiku-4-5 candidate=anthropic/claude-haiku-4-5 reason=empty_response next=openai/gpt-5.4
2026-11-18T02:51:02.161+05:30 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=anthropic/claude-haiku-4-5 candidate=openai/gpt-5.4 reason=model_not_found next=none
2026-11-18T02:51:02.198+05:30 Embedded agent failed before reply: All models failed (2): anthropic/claude-haiku-4-5: CLI backend returned an empty response. (empty_response) | openai/gpt-5.4: Unknown model: openai/gpt-5.4. GPT-5.4 has retired from the ChatGPT-account Codex route. Run `openclaw doctor --fix` to replace it with gp
2026-11-18T02:51:03.236+05:30 [gateway] notification event not delivered node=<node-id>: failed
[2026-11-17T21:20:06.510Z] webchat watching for 150s
[2026-11-17T21:20:23.374Z] webchat sees agent {"sessionKey":"agent:main:main","state":"start","stream":"lifecycle"}
[2026-11-17T21:20:33.822Z] webchat sees agent {"sessionKey":"agent:main:main","state":"starting_model","stream":"run_status"}
[2026-11-17T21:20:42.640Z] webchat sees agent {"sessionKey":"agent:main:main","stream":"thinking"}
[2026-11-17T21:20:44.529Z] webchat sees agent {"sessionKey":"agent:main:main","state":"model","stream":"lifecycle"}
[2026-11-17T21:20:44.533Z] webchat sees agent {"sessionKey":"agent:main:main","state":"fallback_step","stream":"lifecycle"}
[2026-11-17T21:21:02.019Z] webchat sees agent {"sessionKey":"agent:main:main","state":"preparing_workspace","stream":"run_status"}
[2026-11-17T21:21:02.275Z] webchat sees agent {"sessionKey":"agent:main:main","state":"preparing_context","stream":"run_status"}
[2026-11-17T21:21:02.275Z] webchat sees agent {"sessionKey":"agent:main:main","state":"model","stream":"lifecycle"}
[2026-11-17T21:21:02.277Z] webchat sees agent {"sessionKey":"agent:main:main","state":"fallback_step","stream":"lifecycle"}
[2026-11-17T21:21:02.295Z] webchat sees agent {"sessionKey":"agent:main:main","state":"error","stream":"lifecycle"}
[2026-11-17T21:21:03.162Z] webchat sees chat {"sessionKey":"agent:main:main","state":"error","error":"All models failed (2): anthropic/claude-haiku-4-5: CLI backend returned an empty response. (empty_response) | openai/gpt-5.4: Unknown model: openai/gpt-5.4. GPT-5.4 has retired from the ChatGPT-account Codex route. Run `openclaw doctor --fi..."}
```

Node IDs, run IDs and local paths are redacted. All traffic is on 127.0.0.1. The extra `claude-haiku-5-5` CLI turn after each run is OpenClaw's utility session recap, not a retry.

</details>

Merge danger: two-way door. One field on one producer, no stored state or contract change; a revert restores the 2026.11.5 behavior. Blast radius: forwarded device notifications only.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…paid model (#200741)

Root cause: src/gateway/server-node-events-notifications.ts:128 admits phone notifications through `enqueueSessionEventForHost` without the producer's `replyExpectation: "optional"`, so in a WebChat session the `internal_system` turn resolves as result-required (src/agents/reply-completion.ts:116-122) and the CLI runner rejects an authored `NO_REPLY` as `empty_response`, which starts model fallback.

Fixes #200710

Thanks @dawidkulpa for the report with exact before/after counts, and @vaibhav375 for the fix.

## What Problem This Solves

Since 2026.11.5, when an agent decides a forwarded phone notification needs no answer and replies `NO_REPLY`, the turn fails with "CLI backend returned an empty response." and OpenClaw retries it on the fallback model. With a subscription CLI backend and an API-billed fallback, every ignored notification becomes a paid request and an "Unable to finish this reply" card in WebChat.

## User Impact

User impact: agents can ignore phone notifications again. A `NO_REPLY` answer ends the turn silently, with no error card and no fallback model call. Notifications the agent does answer still get their reply.

## Why This Change Was Made

#180106 (e897d98) moved notifications from heartbeat wakes, which allowed silence, onto ordinary host session events, without carrying over that permission. The notification producer now passes `replyExpectation: "optional"`, the same producer-owned waiver cron notifications and session-state notices already pass. Input provenance alone still grants no silence, so other `internal_system` turns keep their result requirement.

The branch keeps the contributor's fix commit. The in-process Gateway test and the docs note are folded into one assertion in the existing notification routing case, which fails on `main` and passes here.

## Evidence

Isolated source Gateway (`ocx src`), loopback, throwaway state. The agent's primary and fallback models are a scripted local CLI backend that logs every call. A WebChat client sends `chat.send` to `agent:main:main`, then a paired `openclaw-android` node sends `notifications.changed` for a promo (model answers `NO_REPLY`) and for a bank alert (model answers with text, the control).

```
main 93d8403
  promo-1: model calls=2  primary -> NO_REPLY, fallback -> "fallback answer for promo-1"
  cli terminal failure: provider=scripted-cli model=primary ... error=CLI backend returned an empty response.
  model fallback decision: decision=candidate_failed ... reason=empty_response next=scripted-cli/fallback
  urgent-1 (control): model calls=1, reply delivered
this PR
  promo-1: model calls=1  primary -> NO_REPLY; no assistant message, 0 empty_response lines, 0 fallback decisions
  urgent-1 (control): model calls=1, reply delivered
```

Regression test: `src/gateway/server-node-events.test.ts` passes 52/52 here; on `main` the two notification routing cases fail on the missing `replyExpectation: "optional"`.

<details>
<summary>Contributor live run with the real claude-cli backend (redacted; Gateway lines in IST, client lines in UTC)</summary>

```
### AFTER (this PR)
[2026-11-17T20:59:06.734Z] phone -> node.event notifications.changed {"change":"posted","key":"proof-1794949146731","packageName":"com.example.shop","title":"Weekend sale","text":"20% off everything this weekend"}
[2026-11-17T20:59:29.741Z] gateway accepted node.event: {"ok":true}
[claude stream] text_delta "text":"NO_REPLY"
2026-11-18T02:29:53.981+05:30 [agent/cli-backend] cli turn: provider=claude-cli model=claude-haiku-4-5 durationMs=9600 outBytes=8 outHash=b07800ad4773
[2026-11-17T20:59:05.295Z] webchat watching for 150s
[2026-11-17T20:59:33.317Z] webchat sees agent {"sessionKey":"agent:main:main","state":"start","stream":"lifecycle"}
[2026-11-17T20:59:45.663Z] webchat sees agent {"sessionKey":"agent:main:main","state":"starting_model","stream":"run_status"}
[2026-11-17T20:59:52.985Z] webchat sees agent {"sessionKey":"agent:main:main","stream":"thinking"}
[2026-11-17T20:59:55.153Z] webchat sees agent {"sessionKey":"agent:main:main","state":"model","stream":"lifecycle"}
[2026-11-17T20:59:55.162Z] webchat sees agent {"sessionKey":"agent:main:main","state":"end","stream":"lifecycle"}
[2026-11-17T20:59:55.165Z] webchat sees chat {"sessionKey":"agent:main:main","state":"final"}

### BEFORE (main)
[2026-11-17T21:20:11.996Z] phone -> node.event notifications.changed {"change":"posted","key":"proof-1794950411995","packageName":"com.example.shop","title":"Weekend sale","text":"20% off everything this weekend"}
[2026-11-17T21:20:21.484Z] gateway accepted node.event: {"ok":true}
2026-11-18T02:50:33.766+05:30 [agent/cli-backend] cli live session start: provider=claude-cli model=claude-haiku-4-5 activeSessions=1
[claude stream] text_delta "text":"NO_REPLY"
2026-11-18T02:50:42.818+05:30 [agent/cli-backend] cli turn: provider=claude-cli model=claude-haiku-4-5 durationMs=9391 outBytes=8 outHash=b07800ad4773
2026-11-18T02:50:42.845+05:30 [agent/cli-backend] cli empty response diagnostics: backend=claude-cli reason=exit exitCode=0 exitSignal=null durationMs=9158 stdoutBytes=19295 stdoutHash=01933c6de95a stderrBytes=0 stderrHash=e3b0c44298fc useResume=false
2026-11-18T02:50:42.854+05:30 [agent/cli-backend] cli terminal failure: provider=claude-cli model=claude-haiku-4-5 durationMs=19303 runId=<id> error=CLI backend returned an empty response.
2026-11-18T02:50:44.443+05:30 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=anthropic/claude-haiku-4-5 candidate=anthropic/claude-haiku-4-5 reason=empty_response next=openai/gpt-5.4
2026-11-18T02:51:02.161+05:30 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=anthropic/claude-haiku-4-5 candidate=openai/gpt-5.4 reason=model_not_found next=none
2026-11-18T02:51:02.198+05:30 Embedded agent failed before reply: All models failed (2): anthropic/claude-haiku-4-5: CLI backend returned an empty response. (empty_response) | openai/gpt-5.4: Unknown model: openai/gpt-5.4. GPT-5.4 has retired from the ChatGPT-account Codex route. Run `openclaw doctor --fix` to replace it with gp
2026-11-18T02:51:03.236+05:30 [gateway] notification event not delivered node=<node-id>: failed
[2026-11-17T21:20:06.510Z] webchat watching for 150s
[2026-11-17T21:20:23.374Z] webchat sees agent {"sessionKey":"agent:main:main","state":"start","stream":"lifecycle"}
[2026-11-17T21:20:33.822Z] webchat sees agent {"sessionKey":"agent:main:main","state":"starting_model","stream":"run_status"}
[2026-11-17T21:20:42.640Z] webchat sees agent {"sessionKey":"agent:main:main","stream":"thinking"}
[2026-11-17T21:20:44.529Z] webchat sees agent {"sessionKey":"agent:main:main","state":"model","stream":"lifecycle"}
[2026-11-17T21:20:44.533Z] webchat sees agent {"sessionKey":"agent:main:main","state":"fallback_step","stream":"lifecycle"}
[2026-11-17T21:21:02.019Z] webchat sees agent {"sessionKey":"agent:main:main","state":"preparing_workspace","stream":"run_status"}
[2026-11-17T21:21:02.275Z] webchat sees agent {"sessionKey":"agent:main:main","state":"preparing_context","stream":"run_status"}
[2026-11-17T21:21:02.275Z] webchat sees agent {"sessionKey":"agent:main:main","state":"model","stream":"lifecycle"}
[2026-11-17T21:21:02.277Z] webchat sees agent {"sessionKey":"agent:main:main","state":"fallback_step","stream":"lifecycle"}
[2026-11-17T21:21:02.295Z] webchat sees agent {"sessionKey":"agent:main:main","state":"error","stream":"lifecycle"}
[2026-11-17T21:21:03.162Z] webchat sees chat {"sessionKey":"agent:main:main","state":"error","error":"All models failed (2): anthropic/claude-haiku-4-5: CLI backend returned an empty response. (empty_response) | openai/gpt-5.4: Unknown model: openai/gpt-5.4. GPT-5.4 has retired from the ChatGPT-account Codex route. Run `openclaw doctor --fi..."}
```

Node IDs, run IDs and local paths are redacted. All traffic is on 127.0.0.1. The extra `claude-haiku-5-5` CLI turn after each run is OpenClaw's utility session recap, not a retry.

</details>

Merge danger: two-way door. One field on one producer, no stored state or contract change; a revert restores the 2026.11.5 behavior. Blast radius: forwarded device notifications only.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit c97a173)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 063675762f70a26ae5f39b5bbcd093e7431a66e9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: whatsapp-web Channel integration: whatsapp-web cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: codex extensions: xai gateway Gateway runtime plugin: file-transfer scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant