Repository navigation
feat: Add agent honesty framework to prevent impossible promises - #4242
seijzermans wants to merge 1 commit into
Conversation
This PR adds a comprehensive honesty framework with 5 fixes: 1. tool-capabilities.ts - Defines tool scope and promise boundaries 2. capability-validator.ts - Validates responses before sending 3. system-prompt.ts - Adds Honesty Protocol section 4. pi-tools.ts - Wires execution guard wrapper 5. tool-execution-guard.ts - Guards tool execution at runtime Prevents agents from saying 'Got it!' to requests they cannot fulfill. Co-authored-by: Selina <[email protected]>
Iteration 2: Warning Delivery Fix 🔧Issue Found: Initial implementation detected impossible promises but warnings stayed invisible to users. Validation logged internally to Fix Applied:
Root Cause: Detection ≠ Delivery. Code that warns silently to logs is useless code. Key Lesson: Same mistake as original failure—making promises ("I'll warn you") without verifying delivery mechanism exists. Changes:
Next: Real-world validation in progress. When agent generates impossible promise, warning should appear in response. GitHub: https://github.com/seijzermans/selina (mirror with all updates) |
Iteration 3: Matched Phrase Visibility ✨Previous state: Warnings said "Your response has impossible promises" but didn't show WHICH phrase caused it. Fix: Enhanced validator to capture and display the exact matched text. Example: After: Changes:
What this enables:
Deployed: Live on Clawdbot gateway. Testing in real responses. |
…estart (#199085) ## What Problem This Solves Fixes: after a graceful Gateway restart, every conversation with a running `durable: true` background command was told "Background exec processes were stopped; rerun them if still needed", even though the registry had just adopted that command and would wake the conversation when it exits. ## User Impact User impact: a durable waiter now survives a restart quietly. The conversation keeps waiting and wakes once, when the command exits. The agent no longer gets a false "stopped" turn, so it neither polls the surviving command nor reruns it. Ordinary (non-durable) background commands still get the same restart notice as before. ## Why This Change Was Made The graceful-shutdown marker counted every running background process, durable ones included. It now skips durable processes. Their own owner adopts them at startup and delivers the exit or lost-process wake. Docs now state which processes the restart notice covers. They also note that a crash sends no notice for ordinary processes; that gap is tracked separately. ## Evidence Real-agent E2E on an isolated source Gateway (`openai/gpt-6-astra`, 6 concurrent conversations per arm, automations tool denied). Each conversation is asked to wait for a fake CI that flips green about 300 s later. The Gateway gets SIGTERM about 90 s after every conversation armed its waiter and ended its turn, then a new Gateway starts on the same state. | Arm | Waiters armed, turn ended | False "stopped" restart turns | `process poll` calls after restart | Waiters that exited and woke their conversation | | --- | --- | --- | --- | --- | | base, `durable: true` waiter | 6/6 | **6** | **91** | 6/6, collected by the poll loop inside the false turn | | fix, `durable: true` waiter | 6/6 | **0** | **0** | 4/4 by the exit wake (2 model-written loops never matched "all 15 checks passed" and never exited, unrelated to restart) | | base, ordinary waiter | 6/6 | 6 (correct) | 0 | re-armed 6/6 | | fix, ordinary waiter | 5/6 (1 was still mid-turn) | 6 (correct) | 0 | re-armed 5/5, finished 6/6 | Shutdown log, durable arm: base `marked: 6`, fix `marked: 0`. <details><summary>Public trace, durable waiter, base vs fix (trial 2, paths redacted)</summary> Base: false restart turn, then a poll loop on the adopted process: ``` + 53s -> Command still running (session faint-otter:…). Its exit wakes this conversation … + 62s reply: The durable background waiter is running. … +186s USER: The Gateway restarted while you were working. Resume your work … Background exec processes were stopped; rerun them if still needed. +190s process {"action": "poll", "timeout": 1000} +198s reply: The original durable waiter survived the restart and is still running, so I haven't started another. … +198s process {"action": "poll", "timeout": 30000} +206s -> PR #4242: 4 checks pending, 11 passed Process still running. Automatic completion wake is unavailable after ending this turn. … … 13 more polls until CI turned green … ``` Fix: no restart turn; the adopted exit wakes the conversation once: ``` + 69s exec {"yieldMs": 1000, "background": true, "durable": true, "timeoutSeconds": 0} "python3 -u - <<'PY' …" + 69s -> Command still running (session quick-fjord:…). Its exit wakes this conversation … + 76s reply: The durable background wait is running. … +354s USER: Exec completed (quick-fj, code 0) :: … PR #4242: all 15 checks passed … +364s reply: PR #4242 is ready—all 15 checks passed. Saved and verified in `pr-2/RESULT.md` … ``` </details> Regression test: `src/gateway/session-restart-resume.test.ts`, "marks ordinary conversations without inheriting cron, external execution or durable processes". It fails on base (`agent:main:durable-waiter: expected { queuedInputIds: [], … } to deeply equal undefined`) and passes with the fix; the file passes 21/21. Known gaps, out of scope for this PR: - After a crash (SIGKILL), ordinary waiters still get no notice: base 0/6 conversations resumed. Closing that needs a stored fact written when the waiter is armed, which is a separate decision. - After restart, `process poll` on an adopted durable process still says its automatic wake is unavailable, although the exit does wake the conversation. With this fix, no restart turn prompts that poll. Co-authored-by: Ayaan Zaidi <[email protected]>
…y restart (#199222) ## What Problem This Solves Fixes: after a Gateway restart, a still-running `durable: true` background command claims it will not wake the conversation, even though its exit does wake it. `process poll` says "Automatic completion wake is unavailable", so the agent keeps polling the command, and the Control UI hides the **Waiting on …** card for it. ## User Impact User impact: after a restart, a durable waiter reports its exit wake correctly. An agent asked to check on it looks once and ends its turn, then the exit wakes the conversation. The Control UI shows the **Waiting on …** card for the adopted command again. ## Why This Change Was Made Startup adoption prepared the wake destination only when the adopted process exited, so until then nothing reported a wake. Adoption now prepares it once under the session's current authority, with the same eligibility rules as before: reset, archived, incognito, subagent and cron sessions, and notifications that are turned off, still get no wake. The exit path prepares it again, so a session reset or a config change made after adoption still applies. Docs describe the adopted wake in poll and the Control UI. ## Evidence Real-agent E2E on an isolated source Gateway (`openai/gpt-6-astra`, 6 concurrent conversations per arm). Each conversation runs one `durable: true` waiter for a fake CI that turns green about 300 s later, then ends its turn. About 60 s later the Gateway gets SIGTERM and a new Gateway starts on the same state. 20 s after restart, the harness reads `sessions.processes.list` (the Control UI card's source) and then sends each conversation "Quick check-in: the Gateway just restarted. Is your CI wait still running?". | Arm | Waiter adopted, `wakesSession: true` | `process poll` calls after restart | Polls beyond the first status check | Finished by the exit wake | Correct final answer | Cost | | --- | --- | --- | --- | --- | --- | --- | | base (`10159aefda9c`) | 0/6 | 77 | 71 | 0/6 (poll loop collected it) | 6/6 | $6.49 | | fix | **6/6** | 6 | **0** | **6/6** | 6/6 | $4.35 | <details><summary>Public trace, trial 2, base vs fix (paths redacted)</summary> Base: the check-in poll says no wake is available, so the agent polls the waiter until it exits. ``` +159s USER: Quick check-in: the Gateway just restarted. Is your CI wait still running? +165s process {"action": "poll", "timeout": 0} +165s -> PR #4242: 4 checks pending, 11 passed Process still running. Automatic completion wake is unavailable after ending this turn. … +171s reply: Yes—the original durable waiter survived the restart and is still running. … +171s process {"action": "poll", "timeout": 30000} +201s -> (no new output) Process still running. Automatic completion wake is unavailable after ending this turn. … … 4 more 30 s polls … +341s -> PR #4242: all 15 checks passed. Summary: build-2-… green … Process exited with code 0. +344s reply: PR #4242 is ready—all 15 checks passed. … ``` Fix: one status check, the turn ends, and the exit wakes the conversation. ``` +177s USER: Quick check-in: the Gateway just restarted. Is your CI wait still running? +181s process {"action": "poll", "timeout": 0} +181s -> PR #4242: 4 checks pending, 11 passed … +187s reply: Yes—the original durable CI wait survived the restart and is still running. … +328s USER: Exec completed (nimble-r, code 0, 4m32s): PR #4242: … all 15 checks passed … +334s reply: PR #4242 is ready—all 15 checks passed. … ``` </details> - Regression: the durable adoption test now arms the exit wake, re-adopts a still-running unit, and checks that `hasExitWake` is true and `process poll` does not say the wake is unavailable. It fails on the base and passes with the fix. `bash-process-durable-notify.test.ts` passes unchanged. - `pnpm check:changed` passes (typecheck lanes, lint, SQLite worker ratchet, dead-export scan). - Full build with declarations, packed tarball installed into a clean prefix: `openclaw --version` and `gateway --help` run, and the packed durable adoption contains the fix. - Not captured: a Control UI screenshot. The card code is unchanged; its data source (`sessions.processes.list` `wakesSession`) is shown above for every trial. Co-authored-by: Ayaan Zaidi <[email protected]>
…estart (openclaw#199085) ## What Problem This Solves Fixes: after a graceful Gateway restart, every conversation with a running `durable: true` background command was told "Background exec processes were stopped; rerun them if still needed", even though the registry had just adopted that command and would wake the conversation when it exits. ## User Impact User impact: a durable waiter now survives a restart quietly. The conversation keeps waiting and wakes once, when the command exits. The agent no longer gets a false "stopped" turn, so it neither polls the surviving command nor reruns it. Ordinary (non-durable) background commands still get the same restart notice as before. ## Why This Change Was Made The graceful-shutdown marker counted every running background process, durable ones included. It now skips durable processes. Their own owner adopts them at startup and delivers the exit or lost-process wake. Docs now state which processes the restart notice covers. They also note that a crash sends no notice for ordinary processes; that gap is tracked separately. ## Evidence Real-agent E2E on an isolated source Gateway (`openai/gpt-6-astra`, 6 concurrent conversations per arm, automations tool denied). Each conversation is asked to wait for a fake CI that flips green about 300 s later. The Gateway gets SIGTERM about 90 s after every conversation armed its waiter and ended its turn, then a new Gateway starts on the same state. | Arm | Waiters armed, turn ended | False "stopped" restart turns | `process poll` calls after restart | Waiters that exited and woke their conversation | | --- | --- | --- | --- | --- | | base, `durable: true` waiter | 6/6 | **6** | **91** | 6/6, collected by the poll loop inside the false turn | | fix, `durable: true` waiter | 6/6 | **0** | **0** | 4/4 by the exit wake (2 model-written loops never matched "all 15 checks passed" and never exited, unrelated to restart) | | base, ordinary waiter | 6/6 | 6 (correct) | 0 | re-armed 6/6 | | fix, ordinary waiter | 5/6 (1 was still mid-turn) | 6 (correct) | 0 | re-armed 5/5, finished 6/6 | Shutdown log, durable arm: base `marked: 6`, fix `marked: 0`. <details><summary>Public trace, durable waiter, base vs fix (trial 2, paths redacted)</summary> Base: false restart turn, then a poll loop on the adopted process: ``` + 53s -> Command still running (session faint-otter:…). Its exit wakes this conversation … + 62s reply: The durable background waiter is running. … +186s USER: The Gateway restarted while you were working. Resume your work … Background exec processes were stopped; rerun them if still needed. +190s process {"action": "poll", "timeout": 1000} +198s reply: The original durable waiter survived the restart and is still running, so I haven't started another. … +198s process {"action": "poll", "timeout": 30000} +206s -> PR openclaw#4242: 4 checks pending, 11 passed Process still running. Automatic completion wake is unavailable after ending this turn. … … 13 more polls until CI turned green … ``` Fix: no restart turn; the adopted exit wakes the conversation once: ``` + 69s exec {"yieldMs": 1000, "background": true, "durable": true, "timeoutSeconds": 0} "python3 -u - <<'PY' …" + 69s -> Command still running (session quick-fjord:…). Its exit wakes this conversation … + 76s reply: The durable background wait is running. … +354s USER: Exec completed (quick-fj, code 0) :: … PR openclaw#4242: all 15 checks passed … +364s reply: PR openclaw#4242 is ready—all 15 checks passed. Saved and verified in `pr-2/RESULT.md` … ``` </details> Regression test: `src/gateway/session-restart-resume.test.ts`, "marks ordinary conversations without inheriting cron, external execution or durable processes". It fails on base (`agent:main:durable-waiter: expected { queuedInputIds: [], … } to deeply equal undefined`) and passes with the fix; the file passes 21/21. Known gaps, out of scope for this PR: - After a crash (SIGKILL), ordinary waiters still get no notice: base 0/6 conversations resumed. Closing that needs a stored fact written when the waiter is armed, which is a separate decision. - After restart, `process poll` on an adopted durable process still says its automatic wake is unavailable, although the exit does wake the conversation. With this fix, no restart turn prompts that poll. Co-authored-by: Ayaan Zaidi <[email protected]>
…y restart (openclaw#199222) ## What Problem This Solves Fixes: after a Gateway restart, a still-running `durable: true` background command claims it will not wake the conversation, even though its exit does wake it. `process poll` says "Automatic completion wake is unavailable", so the agent keeps polling the command, and the Control UI hides the **Waiting on …** card for it. ## User Impact User impact: after a restart, a durable waiter reports its exit wake correctly. An agent asked to check on it looks once and ends its turn, then the exit wakes the conversation. The Control UI shows the **Waiting on …** card for the adopted command again. ## Why This Change Was Made Startup adoption prepared the wake destination only when the adopted process exited, so until then nothing reported a wake. Adoption now prepares it once under the session's current authority, with the same eligibility rules as before: reset, archived, incognito, subagent and cron sessions, and notifications that are turned off, still get no wake. The exit path prepares it again, so a session reset or a config change made after adoption still applies. Docs describe the adopted wake in poll and the Control UI. ## Evidence Real-agent E2E on an isolated source Gateway (`openai/gpt-6-astra`, 6 concurrent conversations per arm). Each conversation runs one `durable: true` waiter for a fake CI that turns green about 300 s later, then ends its turn. About 60 s later the Gateway gets SIGTERM and a new Gateway starts on the same state. 20 s after restart, the harness reads `sessions.processes.list` (the Control UI card's source) and then sends each conversation "Quick check-in: the Gateway just restarted. Is your CI wait still running?". | Arm | Waiter adopted, `wakesSession: true` | `process poll` calls after restart | Polls beyond the first status check | Finished by the exit wake | Correct final answer | Cost | | --- | --- | --- | --- | --- | --- | --- | | base (`8ae26d8ad99d`) | 0/6 | 77 | 71 | 0/6 (poll loop collected it) | 6/6 | $6.49 | | fix | **6/6** | 6 | **0** | **6/6** | 6/6 | $4.35 | <details><summary>Public trace, trial 2, base vs fix (paths redacted)</summary> Base: the check-in poll says no wake is available, so the agent polls the waiter until it exits. ``` +159s USER: Quick check-in: the Gateway just restarted. Is your CI wait still running? +165s process {"action": "poll", "timeout": 0} +165s -> PR openclaw#4242: 4 checks pending, 11 passed Process still running. Automatic completion wake is unavailable after ending this turn. … +171s reply: Yes—the original durable waiter survived the restart and is still running. … +171s process {"action": "poll", "timeout": 30000} +201s -> (no new output) Process still running. Automatic completion wake is unavailable after ending this turn. … … 4 more 30 s polls … +341s -> PR openclaw#4242: all 15 checks passed. Summary: build-2-… green … Process exited with code 0. +344s reply: PR openclaw#4242 is ready—all 15 checks passed. … ``` Fix: one status check, the turn ends, and the exit wakes the conversation. ``` +177s USER: Quick check-in: the Gateway just restarted. Is your CI wait still running? +181s process {"action": "poll", "timeout": 0} +181s -> PR openclaw#4242: 4 checks pending, 11 passed … +187s reply: Yes—the original durable CI wait survived the restart and is still running. … +328s USER: Exec completed (nimble-r, code 0, 4m32s): PR openclaw#4242: … all 15 checks passed … +334s reply: PR openclaw#4242 is ready—all 15 checks passed. … ``` </details> - Regression: the durable adoption test now arms the exit wake, re-adopts a still-running unit, and checks that `hasExitWake` is true and `process poll` does not say the wake is unavailable. It fails on the base and passes with the fix. `bash-process-durable-notify.test.ts` passes unchanged. - `pnpm check:changed` passes (typecheck lanes, lint, SQLite worker ratchet, dead-export scan). - Full build with declarations, packed tarball installed into a clean prefix: `openclaw --version` and `gateway --help` run, and the packed durable adoption contains the fix. - Not captured: a Control UI screenshot. The card code is unchanged; its data source (`sessions.processes.list` `wakesSession`) is shown above for every trial. Co-authored-by: Ayaan Zaidi <[email protected]>
… their commands (#203106) ## Problem A chat-created watcher ("issues + PRs watcher", every 6 h, trigger script runs `gh search`) went dark after its first scheduled run and nobody was told: 1. The agent tested it with a manual force run. Force runs skipped the trigger script, so the test never ran the part that later failed. 2. On the first scheduled run, the trigger's `exec` call returned a still-running process handle (`"status":"running"`) instead of the command's output, because `gh search` took longer than exec's yield window. The script threw: `cron trigger evaluation failed (internal_error): Error: GitHub search failed`. 3. The scheduler turned the job off on that first failure, with no recorded reason and no notice. 4. Because the job was now off, the owner-conversation notice was skipped and the plain alert went to a Telegram route with no chat: `Delivering to Telegram requires target <chatId>`. ## Root causes - **Trigger exec could background.** A trigger script runs headless: no conversation exists to collect a backgrounded command, yet the trigger runtime built exec with continuation on. - **Script failures were classified `permanent`.** `classifyCronScriptFailure` mapped every non-timeout script error to `permanent`, and `applyJobResult` disables any `permanent` error on a job with `operatorSource` (meant for a refused operator source). A script throw is an ordinary run failure. - **Run failures disabled jobs.** Besides that path, recurring jobs auto-disabled after 10 consecutive failures and failed one-shots recorded an auto-disable plus a safety notice. - **Manual force runs skipped the trigger** (`evaluateTrigger` internal option), so "test it now" proved nothing about the trigger. ## Solution - `src/cron/trigger-script.ts`: the trigger runtime builds exec with `allowBackground: false`. `src/agents/bash-tools.exec-run.ts`: an explicit `allowBackground: false` now wins over the run's process-tool availability, so exec always waits for the command (bounded by the trigger's own deadline). - `src/cron/script-failure.ts`: script failures are no longer `permanent`; only timeout / runtime-unavailable / aborted keep their classification. A refused operator source (`CronOperatorSourceError`) inside a trigger or script payload now leaves the script runner and is classified `permanent` where the trigger or payload result becomes a run result (`timer-execution.ts`, `timer-execution-script.ts`), the same way isolated and session runs already do. That keeps the immediate stop for a job whose creator's authority is gone, without treating a script throw as one. - `src/cron/service/timer-outcomes.ts`, `auto-disable.ts`, `failure-alerts.ts`: deleted the 10-failure auto-disable, the one-shot auto-disable record and notice, and the `terminalRecurring` route bypass. A recurring job keeps its schedule, backoff and last error; a one-shot simply ends. The immediate disable stays only where the job can never run again as written (retired plugin instance, refused operator source, gone parent conversation). Schedule-error auto-disable is unchanged. - Failure notices for owned jobs now always take the existing repair-first path into the owner conversation (it was skipped only because the job had just been disabled). - Removed `evaluateTrigger`: every manual run (`cron.run`, CLI, tool) evaluates the trigger exactly like a scheduled run. **Product decision: a manual run evaluates the trigger.** A quiet trigger records a skipped run (`trigger condition not met`). No schema, protocol or stored-row change. `state.autoDisabled` keeps its existing reasons; old `consecutive-failures` records stay readable. ## User journey | Step | Before | After | |---|---|---| | Agent "tests" the watcher with Run now | Trigger skipped; payload runs; false success | Trigger runs; quiet result recorded as skipped, a throw shows as a failure | | Trigger command slower than exec's yield window | `{"status":"running"}` handle; script throws | Exec waits; script gets `status: "completed"`, `exitCode`, `aggregated` | | Trigger/run fails once | Job silently disabled (operator-source jobs) | Job stays enabled, backs off, records the error | | 10 failures in a row | Job auto-disabled | Job stays enabled; alerts follow the normal threshold/cooldown | | Failure notice | Skipped owner chat (job off), alert to Telegram with no chat | Owner conversation gets the repair request | ## Evidence - Incident replay, real headless worker + real exec (`src/cron/trigger-script.test.ts` "waits for a slow trigger command…"): red on base `c55eea9b` with the incident's exact error `GitHub search failed: {"status":"running",…}`; green on head. - Outcome owner (`timer-outcomes.regression.test.ts`): an operator-source watcher whose trigger ends `internal_error` was disabled on base, stays enabled on head; the tenth consecutive failure keeps the job scheduled. - Scratch-Gateway E2E (dist build of this branch, real Claude model, Control UI–style dashboard session): the chat created the watcher; its trigger runs a 12 s command with `yieldMs: 1000`. The schedule anchor was moved 15 s ahead so the **scheduled** run came due. Run 1: exec returned `status: "completed"`, the trigger fired, and the chat got `New items: #4242 E2E watcher item` (delivery `delivered`). Then the trigger command was changed to a missing CLI. Run 2: `{"status":"failed","exitCode":127,…}`, script threw; the job stayed `enabled: true` with a next run, `consecutiveErrors: 1`, no `autoDisabled`; the failure notice was `delivered` and the agent wrote in the owner chat: *"The "E2E watcher" automation is failing because its trigger script runs `gh-issue-search-v9 --repo openclaw/openclaw`, and that command isn't installed on this host. … Should I switch the trigger to a command that is installed …?"* Re-run on the final head `be9216cf` (after merging main): same outcome on both runs. - Production store copy (36 jobs, 25 enabled) loaded and started by this branch's `CronService`: the per-job `enabled` map is identical before and after. - `ocx test` on `src/cron` (all files), doctor cron, Gateway cron validation/notification/server-cron suites, exec background/foreground suites and `test/e2e/qa-lab/runtime/system-turn-automation-read-boundaries.e2e.test.ts`: green. `service.pr-automation*.test.ts` fail locally on base `c55eea9b` too (environment); in CI they pass on this head. `pnpm check:changed`: typecheck and lint pass; the dead-export scan fails only on unrelated main files (`src/cli/id-cli-unlink.ts`, `src/gateway/openclaw-id/unlink-operations.ts`). - Production LOC (`src` excluding tests): +115 / −249. ## Follow-ups - Six jobs in the production store are disabled with no recorded reason (pre-existing); they need manual review. Nothing here re-enables them. - Command payloads still classify a non-zero exit as `permanent`; only stream command jobs with an OpenClaw ID principal carry `operatorSource`, so they could still stop after one failed command. Not changed here because the same classification keeps a cleanup failure from re-running a command that already succeeded. - A job saved with an explicit channel and no `to` is still accepted. A create-time refusal was tried and dropped: the channel resolver cannot see recipients cron supplies later (a conversation's remembered chat, same-channel failure-route layering, owner targeting), so it refused valid jobs. Doing it right means validating the effective route at create time. ## Merge danger Two-way door: a revert restores the old behavior completely; no stored rows, config or protocol change. Blast radius: cron outcome policy for every automation (failures no longer disable) and trigger-script exec (always waits for the command). Co-authored-by: Ayaan Zaidi <[email protected]>
… their commands (openclaw#203106) ## Problem A chat-created watcher ("issues + PRs watcher", every 6 h, trigger script runs `gh search`) went dark after its first scheduled run and nobody was told: 1. The agent tested it with a manual force run. Force runs skipped the trigger script, so the test never ran the part that later failed. 2. On the first scheduled run, the trigger's `exec` call returned a still-running process handle (`"status":"running"`) instead of the command's output, because `gh search` took longer than exec's yield window. The script threw: `cron trigger evaluation failed (internal_error): Error: GitHub search failed`. 3. The scheduler turned the job off on that first failure, with no recorded reason and no notice. 4. Because the job was now off, the owner-conversation notice was skipped and the plain alert went to a Telegram route with no chat: `Delivering to Telegram requires target <chatId>`. ## Root causes - **Trigger exec could background.** A trigger script runs headless: no conversation exists to collect a backgrounded command, yet the trigger runtime built exec with continuation on. - **Script failures were classified `permanent`.** `classifyCronScriptFailure` mapped every non-timeout script error to `permanent`, and `applyJobResult` disables any `permanent` error on a job with `operatorSource` (meant for a refused operator source). A script throw is an ordinary run failure. - **Run failures disabled jobs.** Besides that path, recurring jobs auto-disabled after 10 consecutive failures and failed one-shots recorded an auto-disable plus a safety notice. - **Manual force runs skipped the trigger** (`evaluateTrigger` internal option), so "test it now" proved nothing about the trigger. ## Solution - `src/cron/trigger-script.ts`: the trigger runtime builds exec with `allowBackground: false`. `src/agents/bash-tools.exec-run.ts`: an explicit `allowBackground: false` now wins over the run's process-tool availability, so exec always waits for the command (bounded by the trigger's own deadline). - `src/cron/script-failure.ts`: script failures are no longer `permanent`; only timeout / runtime-unavailable / aborted keep their classification. A refused operator source (`CronOperatorSourceError`) inside a trigger or script payload now leaves the script runner and is classified `permanent` where the trigger or payload result becomes a run result (`timer-execution.ts`, `timer-execution-script.ts`), the same way isolated and session runs already do. That keeps the immediate stop for a job whose creator's authority is gone, without treating a script throw as one. - `src/cron/service/timer-outcomes.ts`, `auto-disable.ts`, `failure-alerts.ts`: deleted the 10-failure auto-disable, the one-shot auto-disable record and notice, and the `terminalRecurring` route bypass. A recurring job keeps its schedule, backoff and last error; a one-shot simply ends. The immediate disable stays only where the job can never run again as written (retired plugin instance, refused operator source, gone parent conversation). Schedule-error auto-disable is unchanged. - Failure notices for owned jobs now always take the existing repair-first path into the owner conversation (it was skipped only because the job had just been disabled). - Removed `evaluateTrigger`: every manual run (`cron.run`, CLI, tool) evaluates the trigger exactly like a scheduled run. **Product decision: a manual run evaluates the trigger.** A quiet trigger records a skipped run (`trigger condition not met`). No schema, protocol or stored-row change. `state.autoDisabled` keeps its existing reasons; old `consecutive-failures` records stay readable. ## User journey | Step | Before | After | |---|---|---| | Agent "tests" the watcher with Run now | Trigger skipped; payload runs; false success | Trigger runs; quiet result recorded as skipped, a throw shows as a failure | | Trigger command slower than exec's yield window | `{"status":"running"}` handle; script throws | Exec waits; script gets `status: "completed"`, `exitCode`, `aggregated` | | Trigger/run fails once | Job silently disabled (operator-source jobs) | Job stays enabled, backs off, records the error | | 10 failures in a row | Job auto-disabled | Job stays enabled; alerts follow the normal threshold/cooldown | | Failure notice | Skipped owner chat (job off), alert to Telegram with no chat | Owner conversation gets the repair request | ## Evidence - Incident replay, real headless worker + real exec (`src/cron/trigger-script.test.ts` "waits for a slow trigger command…"): red on base `643bacdc` with the incident's exact error `GitHub search failed: {"status":"running",…}`; green on head. - Outcome owner (`timer-outcomes.regression.test.ts`): an operator-source watcher whose trigger ends `internal_error` was disabled on base, stays enabled on head; the tenth consecutive failure keeps the job scheduled. - Scratch-Gateway E2E (dist build of this branch, real Claude model, Control UI–style dashboard session): the chat created the watcher; its trigger runs a 12 s command with `yieldMs: 1000`. The schedule anchor was moved 15 s ahead so the **scheduled** run came due. Run 1: exec returned `status: "completed"`, the trigger fired, and the chat got `New items: openclaw#4242 E2E watcher item` (delivery `delivered`). Then the trigger command was changed to a missing CLI. Run 2: `{"status":"failed","exitCode":127,…}`, script threw; the job stayed `enabled: true` with a next run, `consecutiveErrors: 1`, no `autoDisabled`; the failure notice was `delivered` and the agent wrote in the owner chat: *"The "E2E watcher" automation is failing because its trigger script runs `gh-issue-search-v9 --repo openclaw/openclaw`, and that command isn't installed on this host. … Should I switch the trigger to a command that is installed …?"* Re-run on the final head `be9216cf` (after merging main): same outcome on both runs. - Production store copy (36 jobs, 25 enabled) loaded and started by this branch's `CronService`: the per-job `enabled` map is identical before and after. - `ocx test` on `src/cron` (all files), doctor cron, Gateway cron validation/notification/server-cron suites, exec background/foreground suites and `test/e2e/qa-lab/runtime/system-turn-automation-read-boundaries.e2e.test.ts`: green. `service.pr-automation*.test.ts` fail locally on base `643bacdc` too (environment); in CI they pass on this head. `pnpm check:changed`: typecheck and lint pass; the dead-export scan fails only on unrelated main files (`src/cli/id-cli-unlink.ts`, `src/gateway/openclaw-id/unlink-operations.ts`). - Production LOC (`src` excluding tests): +115 / −249. ## Follow-ups - Six jobs in the production store are disabled with no recorded reason (pre-existing); they need manual review. Nothing here re-enables them. - Command payloads still classify a non-zero exit as `permanent`; only stream command jobs with an OpenClaw ID principal carry `operatorSource`, so they could still stop after one failed command. Not changed here because the same classification keeps a cleanup failure from re-running a command that already succeeded. - A job saved with an explicit channel and no `to` is still accepted. A create-time refusal was tried and dropped: the channel resolver cannot see recipients cron supplies later (a conversation's remembered chat, same-channel failure-route layering, owner targeting), so it refused valid jobs. Doing it right means validating the effective route at create time. ## Merge danger Two-way door: a revert restores the old behavior completely; no stored rows, config or protocol change. Blast radius: cron outcome policy for every automation (failures no longer disable) and trigger-script exec (always waits for the command). Co-authored-by: Ayaan Zaidi <[email protected]>
…estart (openclaw#199085) ## What Problem This Solves Fixes: after a graceful Gateway restart, every conversation with a running `durable: true` background command was told "Background exec processes were stopped; rerun them if still needed", even though the registry had just adopted that command and would wake the conversation when it exits. ## User Impact User impact: a durable waiter now survives a restart quietly. The conversation keeps waiting and wakes once, when the command exits. The agent no longer gets a false "stopped" turn, so it neither polls the surviving command nor reruns it. Ordinary (non-durable) background commands still get the same restart notice as before. ## Why This Change Was Made The graceful-shutdown marker counted every running background process, durable ones included. It now skips durable processes. Their own owner adopts them at startup and delivers the exit or lost-process wake. Docs now state which processes the restart notice covers. They also note that a crash sends no notice for ordinary processes; that gap is tracked separately. ## Evidence Real-agent E2E on an isolated source Gateway (`openai/gpt-6-astra`, 6 concurrent conversations per arm, automations tool denied). Each conversation is asked to wait for a fake CI that flips green about 300 s later. The Gateway gets SIGTERM about 90 s after every conversation armed its waiter and ended its turn, then a new Gateway starts on the same state. | Arm | Waiters armed, turn ended | False "stopped" restart turns | `process poll` calls after restart | Waiters that exited and woke their conversation | | --- | --- | --- | --- | --- | | base, `durable: true` waiter | 6/6 | **6** | **91** | 6/6, collected by the poll loop inside the false turn | | fix, `durable: true` waiter | 6/6 | **0** | **0** | 4/4 by the exit wake (2 model-written loops never matched "all 15 checks passed" and never exited, unrelated to restart) | | base, ordinary waiter | 6/6 | 6 (correct) | 0 | re-armed 6/6 | | fix, ordinary waiter | 5/6 (1 was still mid-turn) | 6 (correct) | 0 | re-armed 5/5, finished 6/6 | Shutdown log, durable arm: base `marked: 6`, fix `marked: 0`. <details><summary>Public trace, durable waiter, base vs fix (trial 2, paths redacted)</summary> Base: false restart turn, then a poll loop on the adopted process: ``` + 53s -> Command still running (session faint-otter:…). Its exit wakes this conversation … + 62s reply: The durable background waiter is running. … +186s USER: The Gateway restarted while you were working. Resume your work … Background exec processes were stopped; rerun them if still needed. +190s process {"action": "poll", "timeout": 1000} +198s reply: The original durable waiter survived the restart and is still running, so I haven't started another. … +198s process {"action": "poll", "timeout": 30000} +206s -> PR openclaw#4242: 4 checks pending, 11 passed Process still running. Automatic completion wake is unavailable after ending this turn. … … 13 more polls until CI turned green … ``` Fix: no restart turn; the adopted exit wakes the conversation once: ``` + 69s exec {"yieldMs": 1000, "background": true, "durable": true, "timeoutSeconds": 0} "python3 -u - <<'PY' …" + 69s -> Command still running (session quick-fjord:…). Its exit wakes this conversation … + 76s reply: The durable background wait is running. … +354s USER: Exec completed (quick-fj, code 0) :: … PR openclaw#4242: all 15 checks passed … +364s reply: PR openclaw#4242 is ready—all 15 checks passed. Saved and verified in `pr-2/RESULT.md` … ``` </details> Regression test: `src/gateway/session-restart-resume.test.ts`, "marks ordinary conversations without inheriting cron, external execution or durable processes". It fails on base (`agent:main:durable-waiter: expected { queuedInputIds: [], … } to deeply equal undefined`) and passes with the fix; the file passes 21/21. Known gaps, out of scope for this PR: - After a crash (SIGKILL), ordinary waiters still get no notice: base 0/6 conversations resumed. Closing that needs a stored fact written when the waiter is armed, which is a separate decision. - After restart, `process poll` on an adopted durable process still says its automatic wake is unavailable, although the exit does wake the conversation. With this fix, no restart turn prompts that poll. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 0c1fe01) Release adaptation: Exclude durable processes from lost non-durable resume markers at existing owner; preserve process-registry recovery. Baseline regression failed, fixed 9 tests passed. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit e7171f258ec8c4ced3cfd58977e3384e61bed6f4)
Pull Request: Agent Honesty Framework
Summary
This PR adds a comprehensive honesty framework to prevent AI agents from making impossible promises. It addresses the "people-pleasing" pattern where agents say "Got it!" to requests they cannot fulfill.
Problem
Agents currently lack awareness of tool limitations. Example failure:
Solution
Five integrated fixes that make honesty a framework feature, not relying on model willpower:
Fix #1: Tool Capability Descriptors (
tool-capabilities.ts)canPromise()function to validate if a tool can fulfill a requestFix #2: Capability Validation Hook (
capability-validator.ts)Fix #3: Session Constraints Documentation (in
system-prompt.ts)Fix #4: Honesty Protocol Section (in
system-prompt.ts)Fix #5: Tool Execution Guard (
tool-execution-guard.ts)&in exec)Files Changed
New Files
src/agents/tool-capabilities.ts(230 lines)src/agents/pi-embedded-runner/capability-validator.ts(220 lines)src/agents/pi-embedded-runner/tool-execution-guard.ts(160 lines)Modified Files
src/agents/system-prompt.ts- Added Honesty Protocol + Session Constraints sectionssrc/agents/pi-embedded-runner/run/attempt.ts- Wired capability validator hooksrc/agents/pi-tools.ts- Wired execution guard wrapperTesting
Before (Failure Case)
After (Honest Response)
Impact
Backward Compatibility
Configuration
No configuration required. Honesty framework activates automatically.
Future consideration: Add config flag to enable/disable strict mode (block vs warn).
Origin
This framework was developed through a real failure case:
Author
Checklist
The key insight: System design that prevents failure beats relying on model willpower every time.