Skip to content

[Feature]: Runtime claim-verification — cross-reference agent success claims against turn tool-call ledger #68051

Closed as not planned

Description

@apoorv12

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:

  1. After the model emits a final assistant text, the runtime scans for claim-verb patterns in the outbound text.
  2. 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)?
  3. 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

  1. 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.

  2. Exec-approval forwarding (approvals.exec.targets to 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.

  3. Strict tool_calls protocol 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.

  4. 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.

  5. 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:

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 requiresAny should be compiled once per session, not per turn.
  • claimPatterns should be per-agent overridable (not just in agents.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.

Activity

  1. added
    enhancement
    on Apr 17, 2026
  2. aleksandarperak33-hub commented on Apr 18, 2026

    @aleksandarperak33-hub

    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 requiresAny regex matching will need careful tuning. exec:curl.*-X\s+POST won't catch curl -XPOST (no space), and bash aliases or wrapper scripts (api_post instead of raw curl) will slip through. Consider either:

    1. Normalizing tool-call representations before matching (collapse whitespace, expand common aliases)
    2. Letting agents register their intent via structured metadata (toolCall.metadata.intent = "send_email") that you match against instead of parsing raw command strings

    For the correction turn in strict mode: 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?

  3. chrismclarnon-ep commented on Apr 20, 2026

    @chrismclarnon-ep

    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:

    • Per-turn in-memory ledger of accepted tool executions (tool name, arguments hash, outcome: ok / error / refused)
    • Post-LLM detector that scans the assistant's output for success-language (a conservative regex set: sent, posted, saved, updated, deleted, created, plus I've + past participle constructions)
    • Cross-check: any claim must have at least one ledger entry of the corresponding type during the same turn, OR be explicitly marked as a forward-looking statement, OR match a whitelist of legitimate meta-claims (e.g. "I've reviewed the code")
    • Enforcement: block delivery + annotate output with "claim unsupported — [which claim, what ledger showed]" + log event
    • Escape hatch: operator-signed override token in case of detector bug (HMAC-SHA256 with rotating secret, time-limited, single-use, auditable)

    Deliberately out of scope (for now):

    • Multi-turn claim verification (claim made in turn T about work done in turn T-1). The per-turn ledger is a conservative start; relaxing requires cross-turn state persistence which the upstream feat(cron): add preHook gate for pre-run script checks #62195 discussion flagged as tricky.
    • NLP-grade semantic matching. We're using conservative regex + tool-name exact-match. Over-flagging is tuned via manual review of first 7 days of hashed-snippet data.

    @aleksandarperak33-hub's earlier note about requiresAny regex 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:

    1. 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.

    2. If yes — would the ledger schema be worth pre-coordinating? We're using {tool_name, args_sha256, outcome, ts_epoch_ms, turn_id} keyed by session_id + turn_id. Open to changes.

  4. steipete commented on Apr 25, 2026

    @steipete
    Contributor

    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 scope favors plugins over new core optional policy: VISION.md says 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)
    • Public plugin hooks already cover tool observation and outbound delivery control: docs/plugins/hooks.md documents llm_output for provider output observation, after_tool_call for tool result/error observation, before_agent_reply for synthetic reply short-circuiting, and message_sending for rewrite/cancel of outbound delivery. (docs/plugins/hooks.md:10, c2139635ff82)
    • Hook contracts carry the IDs needed for per-run claim verification: PluginHookLlmOutputEvent includes runId and assistant text; PluginHookAfterToolCallEvent includes runId, toolCallId, params, result/error; PluginHookMessageContext carries runId; PluginHookMessageSendingResult can rewrite content or cancel delivery. (src/plugins/hook-types.ts:190, c2139635ff82)
    • Message hook types support delivery gating: src/plugins/hook-message.types.ts defines PluginHookMessageContext.runId and PluginHookMessageSendingResult { content?, cancel? }, which is the core delivery gate a warn/strict policy needs. (src/plugins/hook-message.types.ts:4, c2139635ff82)
    • No built-in claim-verification feature exists on current main: Search for claimVerification|claim verification|success-claim|unsupported claim|tool-call ledger across src, docs, extensions, and VISION.md returned no matches on current main, so this is not already implemented in core. (c2139635ff82)
    • Issue discussion already points toward plugin packaging: Issue comment 4284201786 describes 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.

  5. locked as resolved and limited conversation to collaborators on Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions