Skip to main content

Module agent_engine

Module agent_engine 

Source

Structs§

AgentRequestContext
AgentTurn
Everything one agent turn needs. Build it with AgentTurn::new and the setters, then run it with run_agent_turn — the single entry point of the agent loop for every channel, the scheduler, recovery and embedded runtimes.
CompactOptions
How a compaction should run.
CompactionOutcome
Result of compact_conversation.
DefaultAgentEngine
TurnContext
Per-turn context that legitimately changes on every request.

Enums§

AgentEvent
An observable event emitted by the shared agent runtime.

Constants§

TOKEN_BUDGET_REFUSAL_PREFIX
Prefix of the canned reply returned when the token budget refuses a turn. Proactive loops (heartbeat / idle check-in / interjection / scheduler) match on this to stay silent instead of delivering the refusal to chat.

Traits§

AgentEngine

Functions§

archive_conversation
Archive the full conversation to a markdown file before compaction. Saved to <data_dir>/groups/<channel>/<chat_id>/conversations/<timestamp>.md.
attach_turn_context
build_system_prompt
build_turn_context
Build the <turn_context> block injected after the system prompt.
compact_conversation
Reduce a conversation: clear older tool outputs first, then (if still needed) replace older history with a structured, incremental summary. A summarizer failure degrades to a mechanical digest; history is never silently dropped.
effective_runtime_data_dir
history_to_claude_messages
maybe_rerun_for_pending
Check if pending messages were queued during the last turn and spawn a new agent run to process them.
message_to_text
Extract text content from a Message for summarization/display.
process_with_agent
process_with_agent_with_events
process_with_agent_with_events_guarded
process_with_agent_with_experience_id
Run the shared loop with a caller-owned durable experience id. This lets supervisors close the record even if they time out and drop the future.
resume_interrupted_turn
Continue an interactive turn from a durable, provider-neutral checkpoint.
run_agent_turn
Run one agent turn. This is the single entry point of the agent loop; the process_with_agent* functions are shorthands for common shapes of AgentTurn.
send_turn_event
Send an event into the live turn for (channel, chat_id) if one is running with an event consumer attached. Returns true when delivered.
should_suppress_user_error
strip_images_for_session
Replace Image content blocks with text placeholders to avoid storing base64 data in sessions.
strip_thinking
Exposed for testing. Strip <think>...</think> and <thought>...</thought> blocks from model output. Handles multiline content and multiple blocks.