Skip to main content
Open-source tools

Code: write agents that are reliable by default

Last updated · Published by Trustabl

Question this stage answers: is the agent written to be reliable?

Most reliability gaps are written into the code: a tool call with no timeout, a loop with no cap, an error the model can't act on. This stage prevents them while the agent is being written, by giving coding agents such as Claude Code and Cursor reliability rules to follow as they write. It's the lowest-effort way to build reliable agents from the first line.

Tool What it does for reliability Repo
Forge (Agent Reliability Skills) Trustabl's reliability skills for coding agents: reads your repo's dependencies and generates a SKILL.md from the reliability rules for your agent SDKs, so Claude Code and Cursor apply them while they write code agent-reliability-skills

Agent frameworks and SDKs are where agent code is written, not reliability tools in themselves, so they are not listed here. Whichever framework you use, the practices below apply.

Coding practices that matter most

Practice Why
Clear, typed tool definitions The model picks and calls tools correctly
A timeout on every network call One slow API can't stall the run
Loop and turn limits The agent can't cycle until it hits a budget wall
Structured errors The model gets errors it can act on
Idempotent data-changing tools Retries don't duplicate side effects
Agent instructions in the repo (AGENTS.md, CLAUDE.md) Coding agents follow the same rules every time

Examples

Short Python examples of the practices above. Most agent frameworks have an equivalent setting.

Timeout on every network call

import httpx

def get_order(order_id: str) -> dict:
    # Fail after 10 seconds instead of stalling the whole run
    resp = httpx.get(f"https://api.example.com/orders/{order_id}", timeout=10.0)
    resp.raise_for_status()
    return resp.json()

Loop and turn limits

# LangGraph: stop the graph after 25 steps
graph.invoke(inputs, config={"recursion_limit": 25})

# OpenAI Agents SDK: stop after 10 turns
result = await Runner.run(agent, user_input, max_turns=10)

Structured errors the model can act on

def lookup_customer(email: str) -> dict:
    try:
        return {"ok": True, "customer": crm.find(email)}
    except crm.NotFound:
        return {"ok": False, "error": "not_found",
                "hint": "Ask the user to confirm their email address."}
    except crm.RateLimited:
        return {"ok": False, "error": "rate_limited",
                "hint": "Wait 30 seconds, then retry once."}

Clear, typed tool definitions

from pydantic import BaseModel, Field

class RefundRequest(BaseModel):
    '''Refund a single paid order. Use only after the user confirms.'''
    order_id: str = Field(description="Order ID, e.g. ORD-12345")
    amount_cents: int = Field(gt=0, description="Refund amount in cents")

Static analysis in the Test stage checks that these practices were actually followed. The checklist lists them as pre-release checks.

Further reading

Next stage: Test