Skip to content

SessionContext

Context available during the session hook.

Extends AgentContext with session-level data: session ID, state, conversation history, and event emission.

agent: object

Agent definition: name, model, instructions.

instructions: string

model: string

name: string

AgentContext.agent


config: Record<string, unknown>

Middleware-specific configuration from the agent definition.

AgentContext.config


history: Message[]

Canonical conversation history (append-only).


sessionId: string

Unique session identifier.


state: Record<string, unknown>

Session state — typed fields with optional reducers, shared across all turns.

emit(event): void

Emit a stream event to the consumer.

StreamEvent

void


registerTool(tool): void

Register a tool on the agent. Call in the agent hook before next().

Tool

void

AgentContext.registerTool