DEV Community

Anindya Obi
Anindya Obi

Posted on

Why Tools Break Agents (And How to Fix Them)

Multi-step agents don’t fail because the model is unreliable.
They fail because tools are poorly defined.

In every broken agent system I’ve analyzed, the same root cause appears:

Unstructured or incomplete tool contracts cause more failures than prompts.

This post breaks down why tool contracts matter, what they must include, and how to design tools that don’t break your agent workflows.

1. What Is a Tool Contract?

A tool contract defines:

  • what the tool expects
  • what it guarantees
  • how it signals errors
  • how its output should be validated

If a tool doesn’t define these clearly, the agent improvises and that’s where brittleness begins.

2. The Four Required Parts of a Reliable Tool Contract
1. Input Schema

Define exactly what the tool accepts:

{
  "input": {
    "text": "string",
    "max_length": "number (optional)"
  }
}

Enter fullscreen mode Exit fullscreen mode

Include:

  • required fields
  • optional fields
  • constraints
  • types
  • allowed ranges If the agent doesn’t know the input shape, it will send malformed inputs.

2. Output Schema

Tools often return:

inconsistent field names

partial structures

nulls disguised as empty lists

arrays sometimes, objects other times

A proper output schema prevents this:

{
  "output": {
    "summary": "string",
    "tokens_used": "number",
    "confidence": "number (0-1)"
  }
}

Enter fullscreen mode Exit fullscreen mode

Downstream nodes depend on this stability.

3. Validation Rules

Validation occurs before and after tool execution.

Input Validation Example:

  • all strings non-empty
  • enums are within expected values
  • no unexpected fields

Output Validation Example:

  • required fields must exist
  • no empty arrays unless specified
  • ranges must be within constraints Without validation, agents treat corrupted data as truth.

4. Error Modes

This is the most neglected part of tooling.

Tools should fail predictably, not randomly.

Define:

  • Typed errors (e.g., MissingFieldError, ParseError, TimeoutError)
  • Retryable vs. non-retryable errors
  • Recovery instructions for the agent Agents can recover from structured errors. They cannot recover from surprise failures.

3. Example Tool Contract Template

Tool: summarize_text

Inputs:
  text: string (required)
  max_length: number (optional, default=150)

Input Validation:
  - text must be non-empty
  - max_length > 0

Output Schema:
  summary: string
  tokens_used: number
  confidence: number (0-1)

Error Modes:
  - MissingFieldError
  - LengthExceededError
  - ToolTimeoutError
  - RetryableNetworkError

Enter fullscreen mode Exit fullscreen mode

This clarity alone prevents a large percentage of agent failures.

4. Why Tools Break Agents
1. Output Drift: Fields change subtly over time.

2. Hidden Error Variants: Tools return random strings instead of typed errors.

3. Ambiguous Inputs: Agents don’t know what to send, so they guess.

4. Inconsistent Schemas: Sometimes an array, sometimes an object.

5. No Validation: Bad data enters the system early and corrupts downstream logic.

These issues collapse multi-step workflows long before the model “hallucinates.”

5. How to Fix Tool Reliability

Checklist:

✔ Define strict schemas
✔ Add pre/post validation
✔ Add typed error modes
✔ Document real tool behavior
✔ Keep tools deterministic
✔ Treat tools like production APIs

This is how you build agents that don’t fall apart at step two.

Takeaway

Tools aren’t secondary to prompts.
Tools are the system.

If your workflow has brittle tools, your agents will always seem unreliable, even if the LLM is performing correctly.

Design tools with clear, strict contracts, and the entire multi-step pipeline becomes more stable.

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.