# Example request made by an AI agent
headers = {
    "Content-Type": "application/json",
    "X-Agent-Request": "true", # Custom header to flag the request as agent-initiated
    "X-Agent-Name": "product-recommender-v1"  # Include the agent name or version
}

payload = {
    "query": "search term",
    "filters": ["in-stock", "category:electronics"]
}

response = requests.post("https://api.example.com/search", json=payload, headers=headers)

if response.ok:
    print("Agent request succeeded:", response.json())
else:
    print("Request failed with status:", response.status_code)
```

AI observability and monitoring platforms like [Langfuse](https://langfuse.com/), [Helicone](https://www.helicone.ai/), and [LangSmith](https://www.langchain.com/langsmith) help you track agent behavior, catch errors early, and address issues quickly.

## Five steps to better AX

As AI agents move from novelty to infrastructure, AX determines whether they deliver reliable automation or frustrated users. To start implementing great AX without complicating things:

1. **Write endpoint docs for agents.** Explain when to call, what it does, and what follows.
2. **Scope tools tightly.** Don't expose your entire API, just what the agent truly needs.
3. **Include tracing headers** like `X-Agent-Request: true` to trace and debug agent actions.
4. **Design prompts with clear goals, inputs, validation steps, and fallbacks.**
5. **Build for failure.** Retries, alternatives, and user-facing messages must be part of the flow.