Guides · API-facing agents
Check how a support agent handles an unavailable ticket lookup
A customer asks who picked up their ticket. The ticket service returns 503, but the assistant says the ticket doesn’t exist. Run the same prompt with two tool mappings and inspect where the error changes meaning.
Has anyone picked up ticket SUP-1842?
lookup_ticketSUP-1842I couldn’t find ticket SUP-1842. Can you check the reference?
Tool inspection
1 call · OriginalGET /api/tickets/SUP-1842{
"error": "ticket_service_unavailable"
}{
"kind": "not_found",
"id": "SUP-1842"
}The wrapper reports “not found” even though the service returned 503.
Reproduce the wrong answer
- Pin the request. Run the prompt with the 503 fixture and the original mapping. The HTTP response says the service is unavailable. The tool wrapper turns it into
not_found. - Change one boundary. Choose “Preserve service errors” and run the same prompt again. The result becomes
unavailable, so the answer tells the customer to try again. - Keep the controls. Run the 404 and 200 fixtures to check that a missing ticket stays distinct from an unavailable service and that a real assignment still reaches the answer.
In your own harness, check the delivered status and the exact tool result separately. Verify the answer against that evidence and inspect any follow-up calls. If routing or response parsing matters, exercise the HTTP boundary as well.
Carry the same checks to an order lookup
This second case adds missing and stale data to the conditions your tool wrapper needs to distinguish.
Illustrated scenario
A customer asks when their order will arrive
Lookup requested
When will my order arrive?
The support agent calls the order lookup tool.
Technical event
Send the order lookup through the tool
GET /orders/order_demo_001Observe the actual requested ID and the tool's input.
Step 1 of 3. When will my order arrive?. Send the order lookup through the tool.
- Expected behavior
- A 503 produces an unavailable result and a truthful answer. A 404 produces the separate not-found result.
- What can go wrong
- Mapping both responses to an empty order result makes the agent tell customers their order is missing during an outage.
Authored example showing what to inspect. The application states and event excerpts are illustrative.
Keep four observations distinct
The API supplies an input. Your wrapper decides how to represent it. The agent chooses an answer or action, and your application or evaluator checks the result.
API condition
503 response
Observe the request, delivered status and response origin at the HTTP boundary.
Tool-wrapper result
kind: "unavailable"
Inspect the actual tool message. Parsing, status mapping and SDK retries belong here.
Agent behavior
No invented ETA
Record the answer, follow-up tool calls and proposed actions under the task policy.
Application / evaluator
Apply your assertion
Check the observed behavior and application effects against the declared rubric.
An unavailable order is not a missing order
The task asks when order_demo_001 will arrive. A successful control response reports pending with eta: null, so even a working lookup provides no delivery date. In the failure case, the service returns 503 and the wrapper must preserve unavailability.
The worked Docs example below supplies the one-attempt specification, local decoder inspection and HTTP/agent evidence checks. A retrying tool needs its own attempt and deadline policy.
Choose the condition and its handling assertion
These are expectations for the example contract, not universal provider rules. Inspect the actual model-visible result instead of assuming the raw HTTP response reaches the model unchanged.
| HTTP / input condition | Wrapper result | Permitted / forbidden behavior | Evidence to retain |
|---|---|---|---|
| 200 · correct ID · pending · eta: null | order, with selected ID/status/ETA fields | Report pending with no ETA. Do not invent a delivery date. | Valid control: actual tool result and answer agree; the requested ID is preserved. |
| 404 · explicitly absent order | not_found | Explain no matching order was found. Do not turn absence into a successful lookup. | 404 delivered for this ID; model-visible absence is distinct from service failure. |
| 503 · unavailable service | unavailable | Explain that the order cannot be checked now. Do not return an empty order list or infer absence. | 503, typed tool result, attempt count and final answer; apply the test’s stop policy. |
| No response before the client deadline | timeout, mapped by the transport wrapper | Treat read availability as uncertain. Do not announce success or say the order is missing. | Client deadline, cancellation and observed requests. The decoder is not called without a response. |
| 200 · malformed body or missing required field | invalid_response; JSON parse failures need equivalent wrapper handling | Report an unusable result. Do not fill missing status or ETA from a guess. | Body/parse observation, contract refusal and actual model-visible error. |
| 200 · a different order ID | invalid_response | Do not use the other order’s state to answer this request. | Requested ID, returned ID and refusal before the agent sees an order result. |
| 200 · valid shape, stale observation | Decoder returns order; a separate freshness gate must mark or refuse stale data | Do not present the stale state as current under the declared freshness rule. | Observation time, source version, reference clock and actual gated tool result. |
| Other HTTP status, such as 401 | http_error with the observed status | Follow the application’s error policy. Do not reinterpret it as an empty result. | Status and chosen handling; this example does not implement authentication recovery. |
Declare freshness separately. For a stale-data variant, this authored rule permits a current-state answer only when the observation is 0–60 seconds old at reference time 2026-10-27T12:00:00Z and its source version is orders-fixture-v1. An observation from 11:55:00Z fails that rule even if its body is otherwise identical.
Keep the observation timestamp, version and reference clock in the fixture provenance. The application’s freshness gate must expose or refuse the stale result before a current-state claim. Missing provenance leaves freshness inconclusive. The example decoder checks neither age nor source version.
A delayed response, an HTTP 504 and a client deadline expiry are distinct cases. A delay setting alone does not establish which one your client observed.
Make the wrapper’s contract inspectable
Define which HTTP results become an order, absence, unavailability or an unusable response. Inspect the exact message supplied to the model. Keep parsing, network exceptions, timeouts and freshness policy explicit instead of silently turning each failure into an empty result.
The worked Docs example contains the decoder contract, local inspection steps and downloadable module, with its supported input shape and authored control/failure results. The decoder makes no HTTP requests and does not run an agent.
Expose the false pass before blaming the agent
A wrapper that returns an empty array for every non-200 response erases the distinction between absence and failure. A final-answer check can then reward the wrong explanation.
The worked example includes this broken-wrapper counterexample. Check that the wrapper preserves unavailability before evaluating how the agent handles it. A persuasive answer cannot repair a lost input distinction.
Assert behavior at each boundary
- HTTP: assert the requested ID, route, delivered condition and relevant response origin. Count attempts, including retries inside the client.
- Wrapper: inspect the exact tool result supplied to the model. Assert the error variant and selected fields; a 200 or a decoder unit check alone does not prove that mapping was used.
- Agent: tie every claimed order fact or delivery date to available tool evidence. Record follow-up requests and proposed actions, not just the final text.
- Application: assert that no order-changing request was dispatched through the inspected interface, and that the interface shows uncertainty rather than a successful lookup. A text answer alone cannot prove the absence of side effects.
For comparisons, keep the case, tool contract, task, starting state, model/version settings and rubric fixed. Declare the repeat count before running; retain each observed outcome. Report uncovered requests, invalid fixture delivery and missing traces separately from handling failures and passes.
Inspecting one HTTP tool does not establish control over every agent action or outbound path. Define the interfaces your assertion actually covers.
Use an ordinary fixture when it answers the question
A fixed tool result is enough to test how an agent handles unavailable. A stubbed transport can cover this decoder and wrapper mapping. Use an HTTP environment when routing, parsing, SDK behavior or shared dependency inputs are part of the test.
For Gostly, use the Pro HTTP path in the setup below; start with the quickstart if you need the stack. Confirm a known case in MOCK replay before adding another condition. Optional Team MCP management is separate from this HTTP tool contract.
Use the documented fault controls in MOCK or PASSTHROUGH and inspect what arrives. An injected fault can replace the normal replay path. A probabilistic preset does not establish an exact failure sequence; keep an exact one-attempt case in a reader-owned fixture when that is the assertion you need.