SPEC-002: Agent¶
- Status: Implemented
- Milestone: M1
- Owners: lead maintainer
1. Purpose¶
Define the one interface an agent (scripted bot, model adapter, human proxy) implements, so any agent works in any world (SPEC-001).
2. Terms¶
- Agent: an object implementing
act. Request: plain data the runner sends. Reply: plain data the agent returns. - Capabilities: flags an agent declares:
tool_calls,vision,json_mode(all default false). - Usage: token counts and cost reported with a reply.
3. Requirements¶
- AGT-001 An agent MUST provide
act(request: dict) -> dictreturning a Reply. - AGT-002 The Request MUST contain:
agent_id,step(int),observation,actions(as fromEnvironment.actions),rules(text fromdescribe()),inbox(messages received since the last act, see SPEC-008) andlimits(remaining steps, seconds and cost, nullable). - AGT-012 The Request MUST also contain
notes: a list of strings telling the agent about its dropped messages (SPEC-008 MSG-011), usually empty. - AGT-003 The Reply MUST contain
action(plain data, the move). It MAY containsay(list of outgoing messages, SPEC-008),usage,metaandreasoning(free text kept for the log). - AGT-004
usage, when present, MUST be an object withinput_tokens,output_tokens(non-negative integers) andcost_usd(non-negative number or null if unknown). Agents that cost nothing (scripted) MAY omit it; the runner records zero. - AGT-005
meta, when present, SHOULD name theproviderand themodelthe provider reports it actually used, so routed or silently changed models are visible in the log. - AGT-006 An agent MUST declare
capabilities() -> dict. Adapters for models without tool calls MUST fall back to plain-text prompting and parse the action from text. - AGT-007 An agent MAY provide
reset(seed: int, agent_id: str) -> None, called once per episode before the firstact. Any randomness in a scripted agent MUST derive from that seed. - AGT-008 An agent MUST NOT receive or touch world internals, the checker, other agents' observations, or the log. It sees only the Request.
- AGT-009 If an agent cannot produce a Reply it MUST raise
AgentError(model failure, unparseable output) orProviderError(network, rate limit, 5xx). The runner treats these differently (SPEC-004). - AGT-010 An agent SHOULD retry provider errors with backoff inside the adapter, up to a configured count (default 5, about 30 seconds of backoff in total), before raising
ProviderError. Each retry MUST be reported to the runner for logging. - AGT-013 An agent MAY provide
close() -> None; the runner MUST call it once after the episode ends, whatever the reason (to stop a subprocess or close a connection). - AGT-014 An agent MAY provide
secrets() -> list[str]: values (such as its API key) the runner MUST redact from the log (SEC-002). - AGT-015 Retries that happened before a successful reply MUST be reported in
meta.retries, a list of{attempt, message}objects (how AGT-010 reports them). - AGT-011 A new scripted agent SHOULD be implementable in under 30 lines without framework changes.
4. Acceptance criteria¶
| Requirement | Test ID | Notes |
|---|---|---|
| AGT-001..003 | AGT-001..AGT-003 |
request/reply shape, validated by schema |
| AGT-004..005 | AGT-004, AGT-005 |
|
| AGT-006..007 | AGT-006, AGT-007 |
same seed gives same scripted moves |
| AGT-008 | AGT-008 |
agent cannot reach world object |
| AGT-009..010 | AGT-009, AGT-010 |
fixtures with 429 and malformed text |
| AGT-011 | AGT-011 |
example agent line count |
5. Examples¶
class Random(Agent): # a scripted agent
def reset(self, seed, agent_id):
self.rng = random.Random(seed)
def act(self, request):
return {"action": self.rng.choice(request["actions"])}
6. Open questions¶
- Should
actbe async? (Draft: sync only; async wrapper later.) - Streaming replies: out of scope for 0.1.
7. Change log¶
- 2026-11-30: Initial draft.
- 2026-11-30: Accepted by the lead maintainer.
- 2026-11-30: Added AGT-012 (
notesin the Request). - 2026-11-30: Added AGT-013 (
close), AGT-014 (secrets), AGT-015 (meta.retries); found while implementing M4. - 2026-11-30: Implemented in v0.1.0; every requirement has a test (PRO-004, PRO-011).
- 2026-11-30: AGT-010 default retries 2 -> 5: free hosted models rate-limit often, and two quick retries aborted most runs (v0.1.1).