pi-agent-core
Installation
SKILL.md
pi-agent-core — Agent Runtime
The Agent class wraps agentLoop with state management, event dispatch, steering/follow-up queues, and abort control. Use Agent for apps; use raw agentLoop only when you need direct async-iterator control without the barrier semantics.
Mental Model
Agent (state + queues + events)
└── agentLoop (double loop: outer=follow-ups, inner=tool-calls+steering)
└── streamAssistantResponse → transformContext → convertToLlm → streamFn → LLM
└── executeToolCalls → prepare → execute → finalize
Key concepts:
AgentMessageis the superset type (LLM messages + custom app messages)convertToLlmfiltersAgentMessage[] → Message[]at the LLM boundarytransformContextoptionally prunes/injects messages before conversion- The Agent class provides a barrier —
message_endcommits the assistant message to state before tool preflight begins. RawagentLoopstreams are observational (no barrier).