Expand description
Session — state container and lifecycle interface for a single conversation.
§Abstraction layers
AgentCore: process-level “agent instance”, holds the built-in tool set and global configuration; it is the root object assembled bydefect-cliand injected intodefect-acp::serveSession: lifecycle unit for a single conversation; holds history, per-session tool table (including MCP), cancel token, and event streamHistory: wrapper around message history, with hooks reserved for compression, token counting, and resume
All three are exposed as traits; concrete implementations live in the session/
submodule within this crate
and at the assembly point in defect-cli; defect-acp interacts with them only
through the traits.
Structs§
- Allowlist
Match - The result of matching a profile tool allowlist against a tool pool.
- Background
Outcome - The outcome produced after a background task completes.
- Background
Progress Config - Configuration for the background task progress view.
- Background
Tasks - Session-level background task table.
Cloneis cheap (innerArc) —DefaultSessionholds one copy, cloned to tools viaToolContext. - Base
Prompt Config - Compaction
Report - Compaction report. The token counts before and after compaction are wrapped into
AgentEvent::ContextCompressedby the main loop. - Compaction
Slot - A session-level background compaction slot.
Cloneis cheap (internally anArc). - Composite
Registry - A “composite” view of the process-level and session-level registries.
- Context
Status - Snapshot of the session’s context usage, returned by
Session::context_status. Powers the/contextslash command (and any client-side context gauge). - Default
Agent Core - Default
AgentCore. - Default
Agent Core Builder - Default
Session - Event
Emitter - Event bus. One instance per session.
- Goal
State - Shared state for one goal-driven loop.
- Loaded
Session - Minimal session data restored from persistent storage.
- Mode
Descriptor - A public description of an optional permission mode. Used by
defect-acpto construct an ACPSessionMode. - Model
Selection - Model selection key: a
(provider vendor, model id)pair. - Permission
Gate - A registry of pending permission requests.
- Progress
Block - A single progress block returned by
peek: kind + text summary (truncated per configuration). - Prompt
Config - Resolved
Session Capabilities - Runtime capabilities resolved at session startup.
- Running
Context - Injects runtime environment context into the system prompt.
- Session
Capabilities Config - Entry point for session-level capability configuration.
- Session
Create Info - Stable information provided to
SessionObserverafter successful creation. - Static
Tool Registry - An immutable mapping from names to tools.
- Static
Tool Registry Builder - A builder for
StaticToolRegistry. - Task
Handle - A handle given to a background task, allowing it to share its history
Arcinto the task table so the control plane can peek at the message chunks it submits to the LLM.Cloneis cheap (innerArc+ small string). - Task
Snapshot - A snapshot of a task in the control plane (returned by
list/peek). - Turn
Config - Configuration for a turn.
- Turn
Runner - All dependencies and accumulated state for a single turn execution.
- VecHistory
- A
Historyimplementation backed byVec<Message>+Mutex, with token accounting. - WebSearch
Capability Config - Configuration for a single capability. Reserved for future capabilities of the same
form, such as
image_generation/code_execution.
Enums§
- Agent
Error - Process-level agent error.
- Background
Result - The final result of a background task.
- Block
Kind - The role/category of a progress block. Directly corresponds to the content of a
crate::llm::Messagesubmitted to the LLM. - Frontend
- How the agent is connected — determines its understanding of the file and command execution environment.
- Session
Init Error - A one-time adjudication failure during session startup.
- Task
Status - Lifecycle status of a background task, exposed via the
inspect_background_taskcontrol plane. - Turn
Error - Reasons why a turn fails.
- Turn
Request Limit - Strategy for capping LLM calls.
- WebSearch
Capability Mode - Toggle for hosted web search capability.
Traits§
- Agent
Core - Process-level agent root object.
- History
- Abstraction over message history — pure storage + token accounting.
- Session
- A single session.
- Session
Loader - Abstraction for restoring a session from persistent storage.
- Session
Observer - Observer for when
AgentCore::create_sessionsucceeds. - Session
Tool Factory - Abstraction for building an additional tool registry for a single session.
- Tool
Registry - Abstraction for a tool registry.
Functions§
- filter_
registry_ by_ allowlist - Restricts a
baseregistry to the subset allowed byallow(glob patterns; seematch_tool_allowlist), producing a new static registry. Used by the top-level--profilepath, which is a leaf agent: a matchedspawn_agentis intentionally dropped (a top-level profile does not dispatch sub-agents). - format_
background_ outcome - Formats a background task outcome into a text block that is fed back into the conversation.
- load_
project_ prompt - Load only the project instruction layer (
AGENTS.md, collected up the directory tree) as a single rendered string, orNoneif there is none. - match_
tool_ allowlist - Match a profile’s
allowlist against the names inbaseplus the virtualspawn_agentmember. Each entry inallowis a glob pattern (viaglobset, the same engine as hooktool_glob/ skill triggers); a bare tool name is the degenerate case of a glob with no wildcards, so exact allowlists keep working unchanged. - new_
session_ id - Generates a session ID as a random UUID v4.
- resolve_
system_ prompt - Errors
Type Aliases§
- Event
Stream - Event stream. Type-erased to support trait object return.