๐—ฆ๐—ฐ๐—ต๐—ฒ๐—บ๐—ฎ ๐—ฉ๐—ฎ๐—น๐—ถ๐—ฑ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—œ๐˜€ ๐—ก๐—ผ๐˜ ๐—œ๐—ป๐˜๐—ฒ๐—ป๐˜ ๐—ฉ๐—ฎ๐—น๐—ถ๐—ฑ๐—ฎ๐˜๐—ถ๐—ผ๐—ป

You use Pydantic for tool calls. You think the agent is safe. It is not.

Pydantic checks the shape. It does not check the intent.

We tracked 40 tool call failures.

31 of 40 calls sailed through validation. They looked correct but were wrong.

A call to cancel an order is structurally perfect. But the user wanted to cancel a subscription. The validator sees a string ID. It passes the call. The user stays angry.

Shape is not intent.

Fix this with a deterministic pre-check.

Check the state before the tool runs.

This stops the wrong-argument errors.

Wrong tool selection is harder. An LLM judge often makes the same mistakes as the agent.

For destructive tools, use a human confirmation step. Ask the user to agree before the action happens.

Source: https://dev.to/james_oconnor_dev/your-schema-validation-passes-and-the-agent-still-picks-the-wrong-tool-the-bug-is-semantic-2i41

Optional learning community: https://t.me/GyaanSetuAi