Nanocodex Agent
The owned lifecycle for one headless OpenAI coding agent.
nanocodex-agent composes the Tower-native Responses state machine from
nanocodex-oai-api with the runtime from nanocodex-tools. A normal consumer
builds one agent, receives a cheap cloneable [Nanocodex] handle and an
independent [AgentEvents] stream, then submits ordered prompts.
Quick start
use ;
# async
The first await means the private driver accepted and ordered the prompt.
[Turn] is both a per-turn event stream and a future for [TurnResult].
Awaiting the turn waits only for its result; event consumption is independent.
The private driver is the sole owner of mutable conversation, transport, tool,
and process state. Cloning [Nanocodex] only clones its command capability;
[Nanocodex::spawn] creates a clean sibling and [Nanocodex::fork] creates an
independent branch from committed history.
Typed events
[AgentEvents] is optional and independent from turn results. Its raw
JSONL-compatible envelope remains lossless, while
AgentEvent::data provides a
normalized domain view:
use StreamExt;
use ;
# async
Components
eventscontains the complete typed lifecycle event taxonomy.inputcontains prompts and multimodal user input.sessioncontains durable session identities and snapshots.usagecontains token accounting and USD estimates.rolloutrecords and restores Codex-compatible sessions.transportexposes advanced Responses and Tower configuration.toolsexposes the complete tool implementation surface.
OpenAI API-key and managed ChatGPT credentials belong to
[nanocodex_oai_api::auth], independently of this lifecycle crate.