Expand description
§entelix-agents
Production agent SDK on top of the entelix Runnable /
StateGraph foundation. Two layers:
Agent<S>— runtime entity wrapping anyRunnable<S, S>with an event sink and (subsequent slices) execution mode + lifecycle observers. The production-facing surface every consumer constructs.- Recipes —
create_react_agent,create_supervisor_agent,create_chat_agent. Each returns a ready-to-streamAgent<StateType>so common patterns are a single call. Nested-supervisor topologies wire ateam_from_supervisoradapter into a parentcreate_supervisor_agent.
Sub-agent permissions follow F7 (default-filtered hand) via
Subagent.
Structs§
- Agent
- Production agent runtime.
- Agent
Builder - Fluent builder for
Agent<S>. - Agent
Entry - One named sub-agent in a
create_supervisor_agentgraph. - Agent
RunResult - Terminal artifact of one agent run.
- Always
Approve - Always returns
Approve— useful as the supervised-mode default when an operator wants the supervised event sequence (ToolCallApproved→ToolStart) but no actual gating logic. - Approval
Layer tower::Layer<S>that gates aService<ToolInvocation, Response = Value, Error = Error>through anApprover. Construct viaApprovalLayer::new; attach to aToolRegistryviaentelix_core::tools::ToolRegistry::layer.- Approval
Request - Read-only context the
Approversees for each decision. - Approval
Service tower::Service<ToolInvocation>produced byApprovalLayer. Public so operators that wire dispatch paths manually can compose it directly.- Broadcast
Sink - Multi-consumer broadcast sink. Each subscriber gets its own
Receiver; slow consumers receiveLaggederrors but the agent never blocks. Suitable forSSEfan-out +OTelexporter - Capture
Sink - In-memory capture sink for integration tests. Every emitted
event is appended to an
Arc<Mutex<Vec<_>>>; tests inspect the vector to assert ordering and content. - Channel
Approver - Production-shape approver backed by an
mpscchannel. - Channel
Approver Config - Configurable timeout for waiting on operator decisions.
- Channel
Sink - Single-consumer mpsc sink. Construct via
Self::new— the caller keeps thetokio::sync::mpsc::Receiverfor downstream consumption (HTTP SSE driver, file logger, etc.). - Chat
State - State for
crate::create_chat_agentand the simplest single-turn recipes — just the conversation so far. - Dropping
Sink - No-op sink — the agent runs to completion without surfacing per-event telemetry. Default when no sink is configured.
- Fail
Open Sink - Composition adapter that swallows the inner sink’s errors and
always returns
Ok(()). - FanOut
Sink - Callback-shaped fan-out — every emitted event reaches every inner sink in registration order.
- Pending
Approval - One in-flight approval — the operator side. Read these from
the
Receiverpaired withChannelApprover; resolve by sending anApprovalDecisionon the embeddedreply. - ReAct
Agent Builder - Fluent builder for a ReAct-style
Agent<ReActState>. - ReAct
State - State for
crate::create_react_agent— messages plus a step count to make traces easier to inspect. - Runnable
Compacting Runnable<Vec<Message>, Message>wrapper that compacts the input message slice through an operator-suppliedCompactorwhen the total character count meets or exceedsthreshold_chars. Below the threshold the wrapper is a no-op delegate — the inner runnable receives the originalVec<Message>unchanged.- Runnable
ToSummarizer Adapter Summarizerthat delegates to anyRunnable<Vec<Message>, Message>— the same shape as a chat model. Prepends a configurable system instruction so the model understands the task even when the buffer itself contains only raw user/assistant turns.- State
Erasure Sink - Adapter that erases an agent’s state type so a single
AgentEventSink<()>can fan in from heterogeneous agents (Agent<ReActState>,Agent<SupervisorState>, operator-defined state types) in a multi-agent system. - Subagent
- A bounded brain↔hand pairing.
- Subagent
Builder - Builder for
Subagent. Construct viaSubagent::builder(model, &parent_registry). - Subagent
Metadata - Compact metadata snapshot of a
Subagentfor parent-side inspection — the LLM-facing identity (name,description) plus the tool surface bound at construction. Operators that list available sub-agents in a parent agent’s system prompt reach for this struct rather than calling each accessor individually. - Subagent
Tool - Wrapper exposing a
crate::agent::Agentas aTool. Built viaSubagent::into_tool. - Summary
Compactor - LLM-summary
Compactor— drops the oldest turns pastkeep_recent_turnsinto a single summarisedTurn::User, leaving the most recent turns verbatim. - Supervisor
State - State for
crate::create_supervisor_agent— messages plus the last-active sub-agent identifier for traceability. - Tool
Approval Event Sink Handle - Refcounted handle for
ToolApprovalEventSink. Stored inentelix_core::ExecutionContextextensions soApprovalLayerfinds the sink without taking it as a constructor argument. - Tool
Event Layer - Layer that emits per-tool
AgentEventvariants to the configured sink. - Tool
Event Service Serviceproduced byToolEventLayer. Generic over the inner service so the layer composes with any tower-stacked tool path.- Tool
Hook Layer - Layer that applies a
ToolHookRegistryaround tool dispatch. - Tool
Hook Registry - Ordered collection of tool hooks.
- Tool
Hook Request - Immutable snapshot of one tool dispatch as seen by hooks.
- Tool
Hook Service Serviceproduced byToolHookLayer.
Enums§
- Agent
Event - Runtime events emitted by the agent during a single
execute/execute_streamcall. - Approval
Decision - Outcome of a single tool-dispatch approval decision.
- Effect
Gate - Selector for which tool dispatches the
ApprovalLayergates through theApprover. Routes by the calling tool’sToolMetadata::effectso operators express intent once at metadata time and the layer honours it without per-tool wiring. - Execution
Mode - Agent-level switch between immediate and human-supervised tool execution.
- Supervisor
Decision - Decision a supervisor router emits each turn.
- Tool
Hook Decision - Decision returned by
ToolHook::before_tool.
Constants§
- DEFAULT_
SUMMARY_ KEEP_ RECENT_ TURNS - Default count of newest turns the
SummaryCompactorkeeps verbatim before summarising the older history into one synthetic turn. Four matches the typical LLM-agent rhythm (most recent user/assistant pair plus one preceding pair) — small enough that summarisation kicks in early, large enough that adjacent context survives. - DEFAULT_
SUMMARY_ SYSTEM_ PROMPT - Default system prompt the
SummaryCompactorsends to its summariser model when the operator does not override. Phrased as a neutral compress-the-prior-conversation instruction so it works across vendors that route system prompts identically.
Traits§
- Agent
Event Sink - Consumer trait the agent calls for every emitted event.
- Agent
Observer - Turn-level agent-lifecycle observer.
- Approver
- Decision-maker for supervised tool execution.
- Message
Runnable Compaction Ext - Extension trait that attaches
RunnableCompactingto anyRunnable<Vec<Message>, Message>. Blanket-impl’d for every such runnable so a model accepting messages — including layered models (OtelLayer,PolicyLayer,RetryService) — can chain.with_compaction(.)without a separate import per concrete type. - Tool
Approval Event Sink - Type-erased sink for tool-approval events. The agent runtime
produces an implementation by adapting its
Arc<dyn AgentEventSink<S>>(seeToolApprovalEventSinkHandle::for_agent_sink); operators implementing custom downstream observability (OTel direct, audit-log direct) can implement this trait directly without going throughAgentEventSink<S>. - Tool
Hook - Hook for tool lifecycle policy and audit extensions.
Functions§
- build_
chat_ graph - Build the single-node chat graph (system message prepend → model
→ finish) without wrapping it into an
Agent. Use this when you want to configure the agent surface (name, sink, approver, observers) viaAgent::builderdirectly. - build_
react_ graph - Builds the compiled ReAct graph (planner ↔ tools ↔ finish loop)
without wrapping it into an
Agent. Use this when you want to configure the agent-level surface (name, sink, approver, observers) directly viaAgent::builder: - build_
supervisor_ graph - Build a supervisor graph that picks among
agentseach turn. - create_
chat_ agent - Build a single-turn chat agent: prepends
system(if non-empty) to the conversation, callsmodel, appends the reply, and finishes. - create_
react_ agent - Builds a ReAct-style agent: model decides; if it emits tool calls, dispatch and loop back; otherwise finish.
- create_
supervisor_ agent - Build a supervisor graph that picks among
agentseach turn. - team_
from_ supervisor - Adapt a supervisor
Agent<SupervisorState>into aRunnable<Vec<Message>, Message>so it can be embedded as oneAgentEntryinside a parent supervisor — the nested-supervisor pattern.
Type Aliases§
- DynObserver
- Convenience type alias for the dynamic-dispatch handle the agent stores internally.