Tool Use & Function Calling
How do you prevent Claude from hallucinating tool arguments?
QUICK ANSWER
Provide detailed descriptions for tool parameters, use enum lists for allowed values, and instruct the model in your system prompt to ask for clarification if required values are missing.
Mitigation Strategies
- Add Schema Enums: If a parameter has a limited set of options, specify them using
enumvalidation. - Add Guidelines: Add an instruction like 'If you do not have the user's account ID, do not guess. Ask the user for it.'
Verified against: Anthropic Prompt Guidelines