# A day out with Grandma

“Plan a rainy day out with Grandma. She can’t use stairs.”

The venue’s old guide says every gallery is accessible. A visitor says the lift is closed. An agent needs to investigate that disagreement before recommending a visit. AgentRun makes the research, judgment, follow-up, and writing separate steps you can inspect and test.

This example uses **fictional sources and prewritten AI answers**. The interpreter, routing, parallel execution, verification callbacks, and handoff are real. It makes no network calls and books nothing. It demonstrates the workflow, not model accuracy or real venue accessibility.

## Run it

From the source directory, with Node 22.19+:

```sh
npm ci
npm run build
node examples/day-out.mjs repair
node examples/day-out-primer.mjs
node --test examples/day-out.test.mjs
```

[The complete example](../examples/day-out.mjs) contains the DSL, source pack, adapters, and CLI. [The primer](../examples/day-out-primer.mjs) isolates the classifier and shows sift/pick. [Tests](../examples/day-out.test.mjs) check the boundaries and the complete runs.

## Follow one run

1. **Route the request.** Jev distinguishes one access question from planning the whole day.
2. **Research in parallel.** One agent reads venue records; another reads the transport information. Each returns claims, exact quotations, source IDs, and missing topics.
3. **Judge the evidence.** The same classifier returns `supported`, `conflicting`, or `missing` using a complete rubric covering every required topic.
4. **Investigate a conflict.** A follow-up agent reconciles the claims. The current notice explicitly replaces the old guide. It confirms a step-free ground floor, but the lift is still closed. A recent-looking page alone would not establish authority.
5. **Write and review.** The first draft promises access to the whole museum. Its source ID and quotation are real, but its meaning overstates the evidence. Semantic review rejects it. The writer submits a qualified ground-floor plan within a two-submission limit.
6. **Check provenance.** Code confirms that source IDs exist and quotations occur in their sources. This catches invented citations; it does not prove that the writer interpreted a source correctly.

The final plan preserves the outdoor walk from the bus stop. An indoor museum does not make the journey rain-proof. It recommends confirming current arrangements before leaving.

## Try the other paths

| Command | What it shows |
| --- | --- |
| `node examples/day-out.mjs ready` | Consistent findings go directly to a qualified plan. |
| `node examples/day-out.mjs repair` | A source conflict triggers investigation, then an overstated draft gets corrected. |
| `node examples/day-out.mjs quick` | One access question skips the parallel venue/travel team. |
| `node examples/day-out.mjs missing` | An events leaflet does not establish access. The workflow asks a person before writing a recommendation. |

Add `--json` to inspect inputs, calls, review submissions, and interpreter events.

## Test one part

The primer copies the actual classifier node and its entire output schema/rubric into a small workflow. It runs saved findings with expected answers: supported, conflicting, and missing. A deliberately wrong answer produces a failed evaluation even though execution completes normally.

These tests establish the wiring of the evaluation, not the quality of a live model. To measure that, supply your real judge, build a representative evidence set, and retain expected outcomes. Then rerun the whole workflow to check interactions and failure paths.

## Sift, then pick

Four venue descriptions become a shortlist. Jev keeps an indoor, step-free museum visit and an aquarium; a stairs-only garden and a hall with unknown access do not pass. Pick chooses the museum for someone interested in local history, keeping the ground-floor-only qualification. If no supplied option fits, it can return no choice.

The primer includes small individual workflows and a composed `selectionWorkflow`. These are separate from the research graph: you can reuse the same primitives in different arrangements.

<a id="connect-your-agent"></a>
## Connect your agent

The source pack stays fictional in `runDayOut()`, including in host mode. You can first test a real host against those known documents:

```js
import { runDayOut } from './examples/day-out.mjs';
import { createJevRunner } from '@agentrun/jev';

// Implement runNode in your host, using the contract below.
const run = await runDayOut('repair', {
  runNode,
  runJudge: createJevRunner(),
});
```

This is an integration outline: `runNode` is supplied by your application. Configure authorized TypeSafe access on the server before using the live judge; see [Jev setup](guide.md#jev). The helper requires both adapters so a partly scripted run cannot quietly appear live.

`runNode` receives the assembled instructions, a JSON user input, an output schema, and—for the writer—a `review(candidate)` callback. Give the step an agent session and only the tools it needs. If review rejects a draft, pass its feedback to the same session; return the accepted result. Observe the cancellation signal and the interpreter’s declared review limit. The [Pi SDK adapter](../packages/pi/README.md) implements this boundary for Pi.

To use your own documents, call `runWorkflow(workflow, input, adapters)` with the exported workflow and a matching input. `runJudge` owns live semantic judgments; agents own investigation and writing. The `.facts` fields are prewritten extraction answers used only by the offline adapter. Remove those fixture annotations when supplying real source documents.

Your outer agent can expose that call as a tool, such as `plan_day_out`. It receives the workflow’s structured result and can continue its own loop. The DSL does not automatically convert an arbitrary agent loop into a graph.

## What passing means

A complete run passed its declared contracts and judgments. A bad reviewer can still approve an unsupported claim; a test explicitly demonstrates that limit. Citation checks, retry limits, and handoff paths make behavior inspectable, but they do not prove real-world truth or provide a security sandbox. Your host controls tools, accounts, effects, and deployment.
