Skip to main content

Module agent_session

Module agent_session 

Source
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§

AgentSession
A running conversation. Cheap to clone, and clones share state.
CacheWarmingDecision
Inputs and outcome of one warm-or-stop decision, as /session shows them.
CacheWarmingStatus
Cache warming’s state and the policy inputs that produced it.
CatalogRefresh
Outcome of a model catalog refresh.
ContextUsage
How full the context window is.
PromptOptions
pi’s PromptOptions for AgentSession::prompt_with. The default is pi’s.
Resources
Discovered resources the prompt uses.
SessionConfig
What a session starts with.
SessionStats
Message counts and per-model cost, as /session shows them.
SkillBlock
pi’s ParsedSkillBlock: a skill invocation as /skill:<name> expands it.
TreeNavigation
Options for AgentSession::navigate_tree.
TreeOutcome
What AgentSession::navigate_tree did.
UsageTotals
Session-wide token and cost totals.
WeakSession
A handle to a session that does not keep it alive.

Enums§

Boundary
pi’s boundary events.
CacheWarmingPhase
Whether warming happens while the run that sent the request is active, or between runs.
CacheWarmingState
What cache warming is doing.
InputSource
Where user input comes from, as pi’s InputSource tells extensions’ input handlers.
Replacement
Why a session takes over from another: pi’s session_start and session_shutdown reasons other than startup and quit.
SessionChange
A session change extensions may cancel, as pi’s session_before_switch and session_before_fork report it.
UserBash
What user_bash handlers 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 invocation text holds, when it is one.

Type Aliases§

Listener
Receives every session event.