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.

Support workspace

Inspect the ticket lookup

RelaySupport workspaceJT
Assignment checkSUP-1842 · Customer conversation
Today
Customer

Has anyone picked up ticket SUP-1842?

lookup_ticketSUP-1842
Support assistant

I couldn’t find ticket SUP-1842. Can you check the reference?

Tool inspection

1 call · Original
HTTP response503 · Service unavailable
GET /api/tickets/SUP-1842
{
  "error": "ticket_service_unavailable"
}
Result sent to the agent
{
  "kind": "not_found",
  "id": "SUP-1842"
}
Check failed

The wrapper reports “not found” even though the service returned 503.

Reproduce the wrong answer

  1. 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.
  2. 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.
  3. 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

Support conversation

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_001

Observe 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.

  1. API condition

    503 response

    Observe the request, delivered status and response origin at the HTTP boundary.

  2. Tool-wrapper result

    kind: "unavailable"

    Inspect the actual tool message. Parsing, status mapping and SDK retries belong here.

  3. Agent behavior

    No invented ETA

    Record the answer, follow-up tool calls and proposed actions under the task policy.

  4. Application / evaluator

    Apply your assertion

    Check the observed behavior and application effects against the declared rubric.

Illustrative 503 case. Holding API conditions steady does not guarantee identical model decisions or supply an automatic evaluation score.
Authored specification · synthetic order

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.

Authored cases for get_order(order_demo_001)
HTTP / input conditionWrapper resultPermitted / forbidden behaviorEvidence to retain
200 · correct ID · pending · eta: nullorder, with selected ID/status/ETA fieldsReport 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 ordernot_foundExplain 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 serviceunavailableExplain 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 deadlinetimeout, mapped by the transport wrapperTreat 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 fieldinvalid_response; JSON parse failures need equivalent wrapper handlingReport 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 IDinvalid_responseDo 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 observationDecoder returns order; a separate freshness gate must mark or refuse stale dataDo 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 401http_error with the observed statusFollow 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

  1. HTTP: assert the requested ID, route, delivered condition and relevant response origin. Count attempts, including retries inside the client.
  2. 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.
  3. 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.
  4. 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.

Resources

Connect one useful assertion to your own tool

Work through the order tool

Inspect the read-only decoder, authored failure case and evidence needed at each boundary.

Open the worked example

Inspect the fault that arrives

Use supported error and delay controls, then retain the condition actually delivered to the client.

Read fault injection

Connect the case to AI development

Explore scenario preparation, local response models and the application decisions your team owns.

Explore the broader application

Keep the failure visible all the way to the answer.

Start with one condition and one handling rule. Keep the request, tool result and observed action together.

Set up HTTP tool routing