Agent

The single public agent class backed by Causal Weave v3.

Constructor

Passing tools: [] disables tools. Omitting tools creates the default workspace tools.

run()

TaskInput is a string or { input, objective? }. A stateful agent serializes concurrent calls. Successful runs update the agent-owned state. Options:
Passing options.state runs against that explicit snapshot and does not mutate the agent-owned session.

streamEvents()

Emits:
  1. metadata before work begins;
  2. zero or more progress events;
  3. one final event after a successful commit.
If the consumer closes early, the run is aborted. Errors are thrown by the iterator.

stream() and streamText()

Both yield the accepted final answer as one string. They do not currently expose provider token deltas.

getState()

Returns a structured clone of committed state. It is undefined before the first successful run unless initial state was supplied.

getGraph()

Returns a visualization view. It is not the lossless persistence format.

reset()

Without an argument, clears committed state. With a snapshot, validates and replaces it. A generation guard prevents an in-flight older run from overwriting a later reset.

Result

Metadata reports run identity, engine, tools, limits, semantic configuration, timing, step count, model and tool calls, and token totals.

AgentRunError

A failed or aborted run throws:
The fields describe diagnostic run state. They do not replace the agent’s last successful commit.