Poka-yoke: Detect and block tool hallucination before API calls #294

Closed
opened 2026-04-11 20:39:24 +00:00 by Rockachopa · 0 comments
Owner

Poka-Yoke Principle: Detection & Shutdown

Category: Tool Hallucination Prevention
Severity: High (model calls non-existent tools, wasting API budget)

Problem

When a model references a tool that doesn't exist in the current toolset (e.g., calling browser_navigate when the browser toolset is disabled), the agent wastes an API call and produces confusing error messages. Tool schema cross-references make this worse.

Error-Proofing Approach

Poka-yoke says: detect the error state and prevent the failure rather than handling it after.

Acceptance Criteria

  1. Add a pre-flight validation in handle_function_call() that checks if the requested tool exists in the active toolset BEFORE making the API call
  2. When a model calls a non-existent tool, return a structured error including: "Available tools: [list]" so the model can self-correct
  3. Generalize the tool_schema_post_processor pattern: strip cross-tool references from schema descriptions when the referenced tool is not active
  4. Log hallucinated tool calls separately for analysis

References

  • AGENTS.md: "DO NOT hardcode cross-tool references in schema descriptions"
  • model_tools.py: get_tool_definitions() post-processing blocks
  • tools/registry.py: central tool registry
## Poka-Yoke Principle: Detection & Shutdown **Category:** Tool Hallucination Prevention **Severity:** High (model calls non-existent tools, wasting API budget) ### Problem When a model references a tool that doesn't exist in the current toolset (e.g., calling `browser_navigate` when the browser toolset is disabled), the agent wastes an API call and produces confusing error messages. Tool schema cross-references make this worse. ### Error-Proofing Approach Poka-yoke says: **detect the error state and prevent the failure** rather than handling it after. ### Acceptance Criteria 1. [ ] Add a pre-flight validation in `handle_function_call()` that checks if the requested tool exists in the active toolset BEFORE making the API call 2. [ ] When a model calls a non-existent tool, return a structured error including: "Available tools: [list]" so the model can self-correct 3. [ ] Generalize the `tool_schema_post_processor` pattern: strip cross-tool references from schema descriptions when the referenced tool is not active 4. [ ] Log hallucinated tool calls separately for analysis ### References - AGENTS.md: "DO NOT hardcode cross-tool references in schema descriptions" - `model_tools.py`: `get_tool_definitions()` post-processing blocks - `tools/registry.py`: central tool registry
Rockachopa added the poka-yoke label 2026-04-11 20:39:24 +00:00
codex-agent was assigned by Rockachopa 2026-04-11 20:58:16 +00:00
Timmy closed this issue 2026-04-12 22:55:42 +00:00
Sign in to join this conversation.
No Label poka-yoke
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/hermes-agent#294