Skip to main content

Crate myco_agent

Crate myco_agent 

Source
Expand description

Drive model context through generation and tool calls at replayable boundaries. Callers supply tool execution, event sinks, context, and persistence callbacks.

§Embedding

Construct Agent with a [GenerativeModel], ToolExecutor, and EventSink. Supply input with Agent::append_input or install history with Agent::replace_context, then await Agent::run. The crate does not read Myco configuration or create sessions, prompts, hosts, or terminal output.

§Ownership and persistence

The executor owns live resources independently of agent history. Calls within a round run concurrently; results are recorded in call order. Checkpoints persist pending effects and their settled observations. Pending tool batches are durable intent, not replayable model context; recover them before reuse.

Cancel a clone of the run’s CancelToken and await the run future to let cleanup finish. Aborting the task bypasses that cooperative completion path. EventSink provides live observations, not a complete durable event log.

See the agent guide and run cargo run -p myco-agent --example headless for an offline model/tool round.

Structs§

Agent
A headless model/tool loop over caller-supplied context and capabilities.
AgentState
Context and control state, without a model, executor, clock, or event sink. Every transition is synchronous; the caller interprets returned effects.
CancelToken
A token which can be used to signal a cancellation request to one or more tasks.
NullEventSink
No-op sink for tests and headless runs.
OperationId
RunOutcome
A run ending at an output cap is distinct from a completed model turn.
TraceContext
Event attribution for frontends and evaluators. Session and thread are present when bound; depth lets displays distinguish nested workers.

Enums§

AgentEvent
Live events emitted by the agent runtime.
AgentInteractionError
Effect
PendingOperation
Durable intent. A tool intent without its result is an unknown external effect after restart, even when dispatch may not actually have begun.
StateError

Constants§

CONTINUE_PROMPT
The user turn sent to resume a reply that max_tokens cut off mid-text.
DEFAULT_MAX_TRUNCATED_RESUMES

Traits§

EventSink
Consumer of AgentEvents (CLI, TUI, metrics, …).
ToolExecutor
Capabilities available to this execution. Ownership and routing belong to the caller.

Functions§

recover_checkpoint
Recover observations without reissuing any pending operation. The caller must persist this context before allowing new effects.
validate_checkpoint
validate_context
Every tool call has exactly one result in the immediately following batch.

Type Aliases§

Async
BeforeGenerationNotice
Supply a pending runtime notice before a generation step. The returned text is appended as internal system content to the latest user input or tool result and checkpointed before generation; this callback does not reload the system prompt. Retries reuse the same input. Consume the notice only when the future completes, since cancellation can drop the future.
Checkpoint
Persist context and pending intent before effects begin, and completed observations before the next effect. Failure stops execution. A pending tool batch is a durable observation, not a valid model input or context fork.