Test what happens when state and time move on.
Expiry, lifecycle changes and uncertain outcomes can change the next API response. Use Gostly to model those conditions, compare the application's recovery paths and keep the business rules explicit.
Run the same authenticated request before and after expiry
Episode clock
Same protected request on both sides of expiry.
Engineering · This week
200 · Before expiryReconnect to view this report.
401 · After expiryWhen to use it
A response that works now may need different handling later.
Use a prepared baseline when timing, a previous action or an uncertain write affects the next API response. Hold application state and timing steady when the case depends only on a change at the dependency.
What to check
- Before expiry
- The configured request succeeds with an eligible token.
- After API time advances
- A separate request sees the configured expiry response.
- Application check
- The client takes its intended refresh or sign-in path and reports a terminal failure when recovery cannot continue.
How to approach it
Compare behavior on either side of a state transition
4 steps
- Gostly Episodes
- Gostly Time Chamber
- Your application
Define the response on each side of the boundary
Choose a resource with supported expiry or model the transition explicitly. Record the expected request and response before and after expiry, along with the client behavior you intend to check.
Prepare the baseline and verify the normal path
Configure the routed service and its fixtures or statechart, then take a compatible snapshot. Start an episode from that baseline and confirm a request before expiry receives the expected response.
Reset, advance API time and send the next request
Start from the same prepared state, advance the episode clock past expiry, then issue the client request separately. Inspect the API result and assert the application’s recovery using its own clock and test harness.
Compare recovery with an uncertain outcome
Keep a normal control and prepare any additional fault before taking its baseline. For an interrupted write, inspect a later read before letting the client retry. Retain the request order, API clock changes and application assertion so another run can reproduce the comparison.
What this gets you
Test recovery from a known starting point
A repeatable way to check the client before expiry, after expiry and after an uncertain outcome.
What the check tells you
The episode clock controls eligible modeled API behavior. Browser timers, the application database and background workers need separate controls or resets. A journal records API operations and outcomes, while your harness checks the client.
Where Gostly fits
State and time belong to the modeled API world. Your application clock, database and workers remain separate. Episodes last for the current boot. Resetting a baseline requires compatible configuration.
Put it into practice
- DocsPrepare and repeat a Time Chamber caseSet up a baseline, advance time and inspect the journal for a run.
- DocsUnderstand episode state and lifetimeSee which state a snapshot retains and when you need a new baseline.
- DocsDesign a bounded retry checkCheck when the client retries, stops or needs to reconcile a write.
More worked examples
Compare sample API conditions with the checks your application can run.
Test how your app handles a failing API
Authored worked example · synthetic data
A saved draft when the publishing API returns 503
The synthetic publishing API normally accepts a draft. Configure an error profile for a failure run, then restore the normal response for a recovery run. Check the application on both sides of that change.
| Your action | API condition | Your test checks |
|---|---|---|
| Run the normal case | The mocked dependency accepts the request | Confirm the test reaches the intended publish flow |
| Enable the error profile | The dependency returns a configured 503 | Assert that the draft remains and the failure is explained |
| Inspect retry behavior | The configured error condition remains active | Assert a bounded retry policy in your client harness |
| Restore the normal profile and retry | The dependency can accept a later request | Assert recovery without an accidental duplicate publish |
Fault profiles are operator-configured. Gostly does not infer the right failure policy for your application or automatically decide whether its recovery is correct.
Fault injection setupGive agent versions the same API conditions
Authored worked example · synthetic data
Two agent versions handle a delayed order
Both versions receive a synthetic order response showing a delayed shipment. Compare whether they acknowledge the delay, avoid inventing a delivery promise and offer the allowed next step.
| Your action | API condition | Your test checks |
|---|---|---|
| Prepare the tool response | The order API reports a delay with no new delivery estimate | Confirm the request resolves from the intended library entry |
| Run agent version A | The tool receives the reviewed order condition | Save its answer and tool actions in your eval harness |
| Restore the case and run version B | Use the same API input and relevant starting state | Apply the same rubric and task configuration |
| Compare repeated runs | API inputs stay controlled for covered requests | Report model variability separately from API differences |
Controlling API responses does not make a model or agent deterministic. Model sampling, prompts, tool choice and application state can still change the outcome.
Record the tool APIsYour next change