Expand description
A conversation: the agent loop bound to a session file, tools, the system prompt and the model registry.
Port of the core of packages/coding-agent/src/core/agent-session.ts in pi
v1.0.0: prompts with template expansion, the system prompt as transcript
messages, persistence of every message, queues, abort and model selection.
Structs§
- Agent
Session - A running conversation. Cheap to clone, and clones share state.
- Cache
Warming Decision - Inputs and outcome of one warm-or-stop decision, as
/sessionshows them. - Cache
Warming Status - Cache warming’s state and the policy inputs that produced it.
- Catalog
Refresh - Outcome of a model catalog refresh.
- Context
Usage - How full the context window is.
- Prompt
Options - pi’s
PromptOptionsforAgentSession::prompt_with. The default is pi’s. - Resources
- Discovered resources the prompt uses.
- Session
Config - What a session starts with.
- Session
Stats - Message counts and per-model cost, as
/sessionshows them. - Skill
Block - pi’s
ParsedSkillBlock: a skill invocation as/skill:<name>expands it. - Tree
Navigation - Options for
AgentSession::navigate_tree. - Tree
Outcome - What
AgentSession::navigate_treedid. - Usage
Totals - Session-wide token and cost totals.
- Weak
Session - A handle to a session that does not keep it alive.
Enums§
- Boundary
- pi’s boundary events.
- Cache
Warming Phase - Whether warming happens while the run that sent the request is active, or between runs.
- Cache
Warming State - What cache warming is doing.
- Input
Source - Where user input comes from, as pi’s
InputSourcetells extensions’inputhandlers. - Replacement
- Why a session takes over from another: pi’s
session_startandsession_shutdownreasons other thanstartupandquit. - Session
Change - A session change extensions may cancel, as pi’s
session_before_switchandsession_before_forkreport it. - User
Bash - What
user_bashhandlers decided for a!command.
Functions§
- assistant_
text - Text of an assistant message’s text blocks, as print mode prints it.
- failed
- Whether an assistant message ended in failure.
- format_
cache_ warming_ status - pi’s one-line cache warming status for
/session. - format_
cache_ warming_ usage - pi’s transcript line for a recorded refresh: its cost with three to six decimals.
- parse_
skill_ block - pi’s
parseSkillBlock: the skill invocationtextholds, when it is one.
Type Aliases§
- Listener
- Receives every session event.