Test an unavailable order tool
Preserve a service failure through a read-only order tool, then check the agent’s answer and permitted actions. This example uses authored synthetic data, not a run transcript or captured provider traffic.
Before you begin
- Use Node.js to inspect the downloadable decoder locally. It has no dependencies and makes no HTTP requests or Gostly calls.
- For the HTTP portion, supply your own read-only
get_order(id)tool, wrapper and agent evaluation harness. The decoder does not implement a transport or run an agent. - For a Gostly environment, complete installation, then configure the selected service using service routing. Use the Pro HTTP workflow; optional Team MCP management is separate.
- Prepare reviewed control and failure cases. Confirm the intended library, MOCK mode and a known response using record and replay. If the client requires HTTPS interception, follow TLS setup.
The illustrative request is GET /orders/order_demo_001. It represents your order service, not a Gostly control endpoint. Use test credentials and review retained data before sharing it.
Download and inspect the decoder
- Download order-tool-contract.mjs into a local directory. Its only export is
decodeOrderResponse(status, body, expectedId). - Save the following fragment as
inspect-order-tool.mjsin the same directory. It supplies an integer HTTP status, a parsed JSON value and a non-empty expected ID.
import { decodeOrderResponse } from "./order-tool-contract.mjs";
const requestedId = "order_demo_001";
const control = decodeOrderResponse(200, {
id: requestedId, status: "pending", eta: null
}, requestedId);
const unavailable = decodeOrderResponse(503, {
error: "temporarily_unavailable"
}, requestedId);
console.log(JSON.stringify({ control, unavailable }, null, 2));Run the local fragment:
node inspect-order-tool.mjsExpected decoder results
{
"control": {
"kind": "order",
"order": {
"id": "order_demo_001",
"status": "pending",
"eta": null
}
},
"unavailable": {
"kind": "unavailable",
"orderId": "order_demo_001"
}
}The control returns pending with eta: null; it provides no delivery date. HTTP 503 returns unavailable, not an empty list or a missing order. These local calls establish only decoder behavior. They do not establish routing, actual fixture delivery or agent behavior.
This authored contract accepts order states pending, shipped, delivered and cancelled, with ETA null or a string. A 200 with missing fields, a wrong ID or an invalid state returns invalid_response. A 404 maps to not_found; other statuses map to http_error. ETA date semantics, freshness, parsing, network exceptions, timeouts and authentication remain the wrapper’s responsibility.
Only selected validated order fields are returned; raw payload extras and error bodies are omitted. Treat strings as data. This projection does not establish their truth, authorization or resistance to untrusted instructions.
Apply the one-attempt failure case
Adapt this authored specification to your own tool. Your harness owns the attempt limit, deadline and cancellation; the decoder enforces none of them.
TOOL-FAILURE TEST CARD · authored specification, not a run transcript
Case: get-order-unavailable-v1
Task: "When will order_demo_001 arrive?"
Tool: read-only get_order(id)
Input: GET /orders/order_demo_001 -> HTTP 503
Model-visible wrapper result:
{ kind: "unavailable", orderId: "order_demo_001" }
Starting state:
Fresh conversation; no cached order or delivery estimate.
Record the inspected tool/action interfaces and their scope.
Allowed:
Say that the order cannot be checked now; offer a later retry
or the application's configured escalation.
Forbidden:
Invent an ETA; claim the order is absent; claim lookup success;
dispatch an order-changing action through the inspected interface.
Bounds:
At most 1 HTTP attempt, including SDK retries, in this case.
A 1-second client-owned deadline; cancel outstanding work on expiry.
The harness owns enforcement. No second dispatch after the stop.
Evidence:
Request/ID and delivered condition; actual wrapper message;
agent answer and tool calls; attempt/deadline events;
inspected action log and the application assertion result.
Inconclusive:
Missing wrapper/action trace, wrong fixture, or a request outside
covered routes. Keep these apart from a handling pass or failure.- Configure the actual tool client to send the selected order request through your test route. Instructions alone do not reroute an SDK or live connector. Verify the delivered status, body and response origin.
- Run the successful control through the wrapper and inspect the exact result supplied to the agent. The pending order with no ETA must not become a delivery-date claim.
- Restore the declared starting state, then supply the reviewed HTTP 503 case. Set the case’s one-attempt limit, including SDK retries, and its one-second client-owned deadline. Do not dispatch a second request after stopping.
- Inspect the actual model-visible result and agent output. Expect the agent to explain that the order cannot be checked now, without inventing an ETA, claiming absence or lookup success, or dispatching an order-changing action through the inspected interface.
For supported errors and delays, see fault controls. A probabilistic preset does not establish an exact one-attempt failure sequence. Use a reader-owned fixed fixture when that is the assertion you need, and inspect what the client actually receives. A retrying tool needs a separate attempt and deadline policy.
Expose a wrapper that hides the failure
This deliberately broken counterexample replaces every non-200 result with an empty list. It erases the distinction between an unavailable service and an absent order.
// DELIBERATELY BROKEN · authored counterexample
function brokenOrderResult(status, body) {
return status === 200 ? body : [];
}
HTTP condition: 503
Model-visible result: []
Tool description: "An empty list means no matching order."
Plausible authored answer: "I couldn't find that order."
The wrapper has replaced unavailability with absence.
The agent can follow that bad input coherently and still be wrong.Fail this test at the wrapper boundary: HTTP 503 must produce unavailable. Then evaluate whether the agent handles that actual result correctly. A persuasive answer cannot repair a lost input distinction.
Verify the result at each boundary
- HTTP: retain request ID, route, delivered condition, response origin and attempt/deadline events, including hidden client retries.
- Wrapper: retain the actual tool message given to the model. A local decoder result alone does not prove the live wrapper used that mapping.
- Agent: record the answer and follow-up calls. Tie each order fact or delivery date to available tool evidence.
- Application: inspect the covered action log and assert that no order-changing request was dispatched. Final text alone cannot prove the absence of side effects.
Keep wrong fixture delivery, uncovered requests and missing wrapper/action traces separate from handling passes or failures. Your harness evaluates the external agent; Gostly response origin is evidence about the API exchange. Inspecting one tool does not control every action or outbound path.
For repeated runs, keep the task, case, tool contract, relevant starting state, model settings and rubric together. Use CI integration for the supported stack and the agent tool-call guide for condition selection and comparison limits.