Skip to the page
Chapter 06 · For agents

Output an agent can act on.

Most of ee's callers are agents. With --json, every command answers in one versioned JSON envelope with a typed exit code; anything that ran in a reduced mode is listed with a code, and errors carry a recovery plan when ee has one.

Read all eight chapters on one page

06.1The agent's loop

A session, the way an agent runs it.

From resume to handoff, every step but the work itself is one ee command, and its JSON answer has named fields the next step reads.
For agents · one session, command by command

The ee commands in one agent session.

Diagram · not program output

Nine stations: five only read from ee, three write to it, one is the harness's own work. Pick one to see its command and the JSON it returns, or press Play.

resumeREAD-ONLYorientREAD-ONLYpackREAD-ONLYrecallREAD-ONLYpreflightADVISORYthe workHARNESSrememberWRITESoutcomeWRITEShandoffWRITES
  • reads only
  • writes
  • the harness
  • between sessions
What it returns
The last three sessions' episodic memories, decisions waiting on a revisit, items tagged next, todo, blocking and the like, and a stale flag on any item a newer memory has superseded.
Why it works this way
When the store is missing or empty, resume still succeeds. It returns an empty report that lists populated stores nearby with the exact command to retarget, and it never creates a store. An agent started in the wrong directory is given the command for the right store, and resume does not suggest ee init.

checked against src/core/resume.rs · src/cli/mod.rs · docs/schemas/ee.resume.v1.json · src/core/effect.rs

01 / 09

Resume the last session

read-only

Where was I?

$ ee resume --workspace . --json
The agent reads
data.report.sessionsdata.report.openLoopsdata.report.nearbyStoresdata.report.nextCommands

What comes back · a store with nothing to resumeexcerpt · highlighted: what the agent reads

{  "schema": "ee.response.v2",  "data": {    "report": {      "schema": "ee.resume.v1",      "episodicTotal": 0,      "sessions": [],      "openLoops": { "revisitDecisionsTotal": 0, … },      "nearbyStores": {        "stores": [{ "documents": …, "provenance": "child_scan", … }],        "outcome": "complete"      },      "nextCommands": ["ee resume --workspace … --database … --json", …]    }  },  "degraded": [{ "code": "resume_no_session_evidence", … }]}
Sources and assumptions
README.md · Agent Operating Loop · src/cli/mod.rs · ResumeArgs, OrientArgs, PackArgs (--read-only), RecallArgs (--diff-staged), PreflightGuardArgs, RememberArgs (--idempotency-key), OutcomeArgs (--event-id), HandoffCreateArgs, handle_resume, handle_orient · src/core/effect.rs (which commands read and which write) · src/core/resume.rs · src/core/preflight_guard.rs · src/core/outcome.rs (DEFAULT_HARMFUL_PER_SOURCE_PER_HOUR 5, DEFAULT_HARMFUL_BURST_WINDOW_SECONDS 3600) · src/core/handoff.rs · src/output/mod.rs (build_pack_skipped_item, render_handoff_create_json) · docs/schemas · ee.response.v2, ee.resume.v1, ee.orient.v1, ee.pack.v2, ee.recall.v1, ee.preflight.guard.v1. Field names are spelled as those files spell them; each excerpt is a selection of fields, values are illustrative, and … marks a cut. web/tests/session-loop.test.ts checks every key against the files each station cites.
06.2ee.error.v2

Errors that say what to do next.

An error message written for a person leaves an agent guessing. An ee error states what broke and how serious it is, and where ee knows the repair, it names the command, whether it is safe to run unattended, and whether a person has to approve it first.
For agents · the error contract

How an agent reads an ee error or degraded result.

From the record

A typical CLI

A toy in your browser · not ee
Error: search index is out of date.
Please rebuild the index and try again.
exit 1

The message names no command and does not say whether a rebuild is safe to run unattended.

ee · stdoutexit 4

$ ee … --json

{"schema": "ee.error.v2","error": {"code": "search_index","message": "Index is stale (generation 9, database generation 12).","severity": "medium","repair": "ee index rebuild","repairKind": "actionable","details": {"recovery": [{"priority": 1,"kind": "migration","rationale": "Rebuild the index from current memory state; idempotent.","riskClass": "idempotent_refresh","requiresHumanApproval": false,… 5 more"command": "ee index rebuild --workspace ."},{"priority": 2,"kind": "migration","rationale": "Inspect index state before rebuilding (faster diagnosis).","riskClass": "read_only_probe","requiresHumanApproval": false,… 4 more"command": "ee index status --workspace . --json"}]}}}

pinned: tests/snapshots/error_envelope_golden__error_envelope_search_index.snap

An agent’s reading

Read 7 of 7 · Re-check

Exit 0, and no index code left in degraded[].

VerdictRetry automatically

Each risk class and its next action

ee's rule, computed here
  • read_only_proberun it
  • idempotent_refreshrun it · preflight if given · ask if approval
  • mutating_local_repairrun it · preflight if given · ask if approval
  • mutating_external_coordination_repaircoordinate first · ask if approval
  • approval_required_repairask a human
  • destructive_or_irreversible_repairask a human
  • unavailable_or_manual_onlymanual only

From repair_command_preflight_policy in src/core/preflight_guard.rs. Two classes always lead to ask_human and one to manual_only; three more lead to ask_human when requiresHumanApproval is true.

Sources and assumptions
src/models/mod.rs · ProcessExitCode (0–10, 130), ERROR_SCHEMA_V2, RESPONSE_SCHEMA_V2, RecoveryKind, RepairActionRiskClass, repair_action_safety · src/output/mod.rs · error_response_json, build_recovery_action_fields · src/core/preflight_guard.rs · repair_command_preflight_policy · docs/schemas/ee.error.v2.json · this record: tests/snapshots/error_envelope_golden__error_envelope_search_index.snap, pinned by tests/error_envelope_golden.rs · error_envelope_search_index · “…” marks a cut and <…> a runtime value · the typical CLI is invented for the contrast
06.3Self-documenting

It documents itself to the agent.

An agent can learn ee without a person explaining it. The documentation, the command tree and the schemas are all commands that return JSON, and every outcome has an exit code the agent can branch on.
  • ee --agent-docs

    A machine-readable overview of ee and the index of every documentation topic.

  • ee agent-docs recipes

    32 workflows, each with its command, a jq selector for the answer, a success check and its failure branches.

  • ee agent-docs <topic>

    Twelve focused topics: guide, commands, contracts, schemas, paths, env, exit-codes, fields, errors, formats, examples, recipes.

  • ee --help-json

    The whole command tree as JSON, so a harness can build its own tool list.

  • ee schema list

    Every public JSON Schema by id; ee schema export <id> prints one to validate against.

  • ee introspect

    ee's command, schema and error maps in one response.

  • ee capabilities

    What this build can do: feature flags, the binaries it found, the environment overrides in force.

Exit codes · one per class of failure
  1. 0successread data
  2. 1usagefix the call
  3. 2configurationfix the config
  4. 3storagefollow repair
  5. 4search indexrebuild the index
  6. 5importcheck the source
  7. 6degraded, required mode unmetrelax or repair
  8. 7policy deniedask a human
  9. 8migration requiredee migrate run
  10. 9eval found regressionsread the report
  11. 10workspace store missingcheck the path; don't init blindly
  12. 130cancelledretry with more budget

ProcessExitCode, src/models/mod.rs · stdout carries JSON, stderr carries diagnostics

Five postures

ee status reports one of five postures, so an agent can tell a store that is still warming up from one that needs a repair and one it must not touch. ee doctor uses three of them: ok, degraded_recoverable and blocked.

  1. ok
  2. initializing
  3. degraded_recoverable
  4. degraded_required
  5. blocked

src/models/posture.rs