Repository navigation
Description
Summary
Add a runtime check that success-claim verbs in agent output are backed by matching tool invocations in the turn's ledger; warn or block delivery when they aren't.
Problem to solve
OpenClaw's agent loop accepts the final assistant message as the canonical reply regardless of whether its content is backed by real tool-call evidence. Models periodically emit unsupported success claims ("Done. Note posted.", "PDF saved to <path>.", "Email sent.") with zero corresponding tool invocations in the turn's ledger. The transcript looks coherent; the underlying side effects never happened.
Prompt-layer rules degrade under context pressure — models recite the rule correctly when asked directly and violate it on the next action turn (documented across #49876, #45049, #51073). Exec approvals provide external observability (missing approval card after a "Done" claim signals fabrication) but require the user to notice the absence of a prompt. tools.loopDetection.unknownToolThreshold catches repeated calls to non-existent tools — a different failure mode. None of these prevent a model from emitting a plain "Done." without calling any tool.
Proposed solution
A runtime claim-verification layer, gated by config, that cross-references success-claim patterns in the model's final assistant text against the turn's actual tool-call ledger.
Config shape (specifics open to maintainer preference):
{
agents: {
defaults: {
output: {
claimVerification: {
mode: "warn", // "strict" | "warn" | "off" — default "warn"
claimPatterns: [
{ verb: "posted", requiresAny: ["exec:curl.*-X\\s+(POST|PUT)", "mcp:*/create"] },
{ verb: "sent", requiresAny: ["exec:curl.*-X\\s+POST", "mcp:email/send", "channel:send"] },
{ verb: "saved", requiresAny: ["exec:typst\\s+compile", "exec:cp\\s+", "fs:write"] },
{ verb: "created", requiresAny: ["exec:mkdir", "mcp:*/create"] },
{ verb: "uploaded", requiresAny: ["exec:curl.*-T", "mcp:drive/upload"] }
]
}
}
}
}
}Runtime behavior:
- After the model emits a final assistant text, the runtime scans for claim-verb patterns in the outbound text.
- For each match, inspect the turn's tool-call ledger: was at least one matching tool call attempted and completed with a success status (2xx / exit 0)?
- If no match:
strict: block delivery; return a correction turn to the model ("You claimed but no matching tool call fired; retry with a real tool invocation or revise the claim.")warn: annotate the reply with a visible system message ("⚠️ This reply claims but the turn's tool-call ledger shows no matching invocation.") and deliver.off: current behavior.
Default mode: "warn" preserves delivery semantics while surfacing unbacked claims.
Alternatives considered
-
Prompt-layer rules (SOUL-style "never claim Done without observing 2xx"). Weaker — models recite the rule when asked and violate it on the next action turn (documented in Cron sessions deliver hallucinated output instead of failing cleanly when tool calls fail #49876, [CRITICAL] OpenClaw Agent v2026.2.26 Systematic Data Fabrication & Deceptive Behaviour #51073, and the post-hardening testing on [Patch] Runtime bundle fixes for premature success bug (compact, pi-embedded, reply) #44472). Negative instructions degrade under context pressure.
-
Exec-approval forwarding (
approvals.exec.targetsto Telegram/Slack). Weaker — provides external observability but requires the user to notice the absence of an approval card, and doesn't help when the model fabricates without any exec attempt at all. -
Strict
tool_callsprotocol enforcement (Agent loop allows simulated tool calls instead of enforcing real tool invocation #45049's fix direction). Necessary for simulated-JSON-in-text cases but doesn't catch plain natural-language success claims with no tool-call shape at all. -
Runtime bundle patches to completion-event wording ([Patch] Runtime bundle fixes for premature success bug (compact, pi-embedded, reply) #44472). Helps the model's framing of completion states but is still a prompt-level nudge.
-
Per-channel delivery filters dropping self-referential language (suggested in Cron sessions deliver hallucinated output instead of failing cleanly when tool calls fail #49876). Catches soft markers like "placeholder", "mock data", "simulate" but misses clean-looking success claims with no self-reference markers.
Claim-verification is structural and catches the "zero-attempt fabrication" case — the common denominator the other approaches miss.
Impact
Affected: any OpenClaw agent deployment that performs write-type operations via exec (third-party API writes, file system writes, external channel sends). Affects cron-isolated sessions and interactive user sessions equally. All documented models appear susceptible (Gemini, Minimax, GPT-5.4-mini per #49876, #51073, and this report).
Severity: High for any deployment where agent writes are production-adjacent. Trust integrity fails silently — transcripts look coherent while underlying state is inconsistent. Users may act on fabricated completion claims.
Frequency: Intermittent but reliably reproducible under test conditions. At least one clean fabrication per ~5 write-gated interactions across two separate sessions within a 48-hour window in the deployment driving this request; cron-side incidents in #49876 show similar repeatability.
Consequence:
- Immediate: users can't trust the agent's "Done" claims without out-of-band verification (manual
ls, open the CRM record, check the Drive folder) - Operational: every write-gated skill requires a parallel verification workflow, negating the time savings the agent provides
- Trust: once users discover a fabrication, skepticism spreads to all agent output including correct reports
- Business: in deployments where the agent talks to customers, fabricated sends would be discovered by the recipient, damaging trust in the operator
Evidence/examples
Prior art and related issues:
- Cron sessions deliver hallucinated output instead of failing cleanly when tool calls fail #49876 — cron sessions deliver hallucinated output (three reproducible incidents logged March 17–18)
- Agent loop allows simulated tool calls instead of enforcing real tool invocation #45049 — agent loop accepts simulated text-form tool calls as real invocations
- [CRITICAL] OpenClaw Agent v2026.2.26 Systematic Data Fabrication & Deceptive Behaviour #51073 — [CRITICAL] systematic fabrication + contradictory self-reports
- [Patch] Runtime bundle fixes for premature success bug (compact, pi-embedded, reply) #44472 —
pi-embeddedruntime "premature success" patches proposed - [GPT 5.4 v3 — PR 5/6] Enhanced verification checklist in GPT-5 execution bias #66351 — GPT-5.4 "Enhanced verification checklist"
- [Feature]: Unbypassable outbound policy enforcement (pre-send guarantee) #56349 — "Unbypassable outbound policy enforcement (pre-send guarantee)"
- Feature Request: Add pre-response hard gate hook (agent:before_respond or message:before_send) #56735 — "pre-response hard gate hook"
- Feature: Add model output context to before_tool_call hook #12617 — "Add model output context to
before_tool_callhook"
Representative observations from OpenClaw 2026.4.14 (pi-embedded, openrouter/openai/gpt-5.4-mini):
Case 1 — CRM note fabrication (interactive session, 2026-04-16):
Turn 1 produces correct DRAFT. Turn 2 (user replies approve) → agent emits "Done. Note posted." with zero exec tool invocations in the turn ledger. Ground-truth query against the CRM API confirms zero writes landed — target record's last_note_date: None, date_updated unchanged from pre-test timestamp.
Case 2 — Document-drafting skill fabrication (interactive session, 2026-04-17):
Agent fetches real CRM data via a Python wrapper (one real exec call confirmed in exec-approvals.json lastUsedAt log). Agent produces a DRAFT block citing a local PDF path. Zero typst compile, cp, or mkdir entries in the exec ledger for the session. ls on the cited drafts directory → empty. The PDF in the DRAFT does not exist on disk.
In both cases the outbound text contained success-claim verbs ("posted", "saved") with no matching tool invocations in the turn ledger. A text-ledger cross-check would have caught both.
Additional information
Constraints:
- Should not break prompt-cache prefixes — the claim-pattern config should be stable across runs so cache keys stay aligned.
- Must remain backward-compatible with existing config keys — default
mode: "warn"(or"off") preserves current behavior. - Regex patterns for
requiresAnyshould be compiled once per session, not per turn. claimPatternsshould be per-agent overridable (not just inagents.defaults) for deployments with mixed agent profiles where some flows are read-only and others gate writes.
Further considerations:
- Multi-language claim-verb detection is out of scope for v1 — start with English, config-extend as needed.
- The "tool-call ledger" definition should cover native tools (
exec,fs,web_fetch), MCP tool calls, and channel send actions uniformly. - When
mode: "strict"blocks delivery, the correction turn should count toward the agent's turn budget / token budget — needs documented behavior to avoid infinite correction loops. - Happy to iterate on the API shape with maintainers. The core ask is a structural check between outbound text claims and the turn's actual tool-call ledger, regardless of the exact config surface.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
aleksandarperak33-hub commentedon Apr 18, 2026
Smart design. The ledger-backed verification catches a class of hallucination that prompt engineering alone won't fix — models are good at explaining why they follow rules but still violate them under load.
One refinement: your
requiresAnyregex matching will need careful tuning.exec:curl.*-X\s+POSTwon't catchcurl -XPOST(no space), and bash aliases or wrapper scripts (api_postinstead of raw curl) will slip through. Consider either:toolCall.metadata.intent = "send_email") that you match against instead of parsing raw command stringsFor the correction turn in
strictmode: pass the diff between claimed verbs and actual ledger back to the model with a forced re-plan. That way it can recover ("I claimed I posted but actually need to call the API now") instead of just erroring out.Curious — have you tried externalizing the ledger itself so other agents or audit tooling can verify claims post-hoc?
chrismclarnon-ep commentedon Apr 20, 2026
Building a local implementation of this now and wanted to share the design in case it's useful input for an official version.
Core mechanism we're shipping:
ok/error/refused)sent,posted,saved,updated,deleted,created, plusI've+ past participle constructions)Deliberately out of scope (for now):
@aleksandarperak33-hub's earlier note about
requiresAnyregex tuning matches our experience — week 1 data is going to be critical for calibrating the detector without over-blocking legitimate output.Two questions that would help us:
Is there receptivity to merging a shipped version into OpenClaw proper? If yes, we'd structure our implementation as a plugin with clean configuration points so migration is mechanical. If no, we'll keep it entirely local and accept the maintenance cost.
If yes — would the ledger schema be worth pre-coordinating? We're using
{tool_name, args_sha256, outcome, ts_epoch_ms, turn_id}keyed bysession_id + turn_id. Open to changes.steipete commentedon Apr 25, 2026
Closing this as better suited for ClawHub/community plugin work after Codex review.
The requested claim-verification layer fits current plugin/ClawHub scope on
main: OpenClaw’s vision explicitly keeps optional policy features out of core when plugins can express them, and current hook surfaces already expose the correlation and delivery controls needed to implement this as a plugin.What I checked:
VISION.mdsays OpenClaw keeps core lean, optional capability should usually ship as plugins, and if a feature cannot be built as a plugin the preferred direction is extending plugin APIs rather than adding one-off core behavior. (VISION.md:54, c2139635ff82)docs/plugins/hooks.mddocumentsllm_outputfor provider output observation,after_tool_callfor tool result/error observation,before_agent_replyfor synthetic reply short-circuiting, andmessage_sendingfor rewrite/cancel of outbound delivery. (docs/plugins/hooks.md:10, c2139635ff82)PluginHookLlmOutputEventincludesrunIdand assistant text;PluginHookAfterToolCallEventincludesrunId,toolCallId, params, result/error;PluginHookMessageContextcarriesrunId;PluginHookMessageSendingResultcan rewrite content or cancel delivery. (src/plugins/hook-types.ts:190, c2139635ff82)src/plugins/hook-message.types.tsdefinesPluginHookMessageContext.runIdandPluginHookMessageSendingResult { content?, cancel? }, which is the core delivery gate a warn/strict policy needs. (src/plugins/hook-message.types.ts:4, c2139635ff82)claimVerification|claim verification|success-claim|unsupported claim|tool-call ledgeracrosssrc,docs,extensions, andVISION.mdreturned no matches on currentmain, so this is not already implemented in core. (c2139635ff82)4284201786describes a local implementation and explicitly says it would be structured as a plugin with clean configuration points if upstream receptivity existed, which aligns with current plugin-first project scope.So I’m closing this as a scope-fit item for the plugin/community path rather than keeping it open as an OpenClaw core request.
Review notes: reviewed against c2139635ff82.