Skip to content

Interface: ExecutionContext

@providerprotocol/agents


@providerprotocol/agents / index / ExecutionContext

Defined in: src/execution/types.ts:156

Context passed to execution strategies containing all resources needed for execution.

The ExecutionContext bundles together the agent reference, LLM instance, input message, current state, tools, and hooks. Execution strategies use this context to perform their work without needing direct access to the Agent instance.

The context is immutable - strategies should use state.with*() methods to create new state snapshots rather than mutating the provided state.

// ExecutionContext is created internally by the Agent
const context: ExecutionContext = {
agent: { id: 'agent-123', system: 'You are helpful.' },
llm: llmInstance,
input: new UserMessage('Hello'),
state: AgentState.create(),
tools: [weatherTool, searchTool],
strategy: { maxIterations: 5 },
};
const result = await strategy.execute(context);

agent: AgentRef

Defined in: src/execution/types.ts:158

The agent being executed (minimal reference)


optional checkpoints: CheckpointStore

Defined in: src/execution/types.ts:172

Checkpoint store for state persistence (optional)


input: Message

Defined in: src/execution/types.ts:162

The user input message to process


llm: LLMInstance

Defined in: src/execution/types.ts:160

The bound LLM instance configured for this agent


optional sessionId: string

Defined in: src/execution/types.ts:174

Session ID for checkpointing continuity


optional signal: AbortSignal

Defined in: src/execution/types.ts:170

Abort signal for cancellation support


state: AgentState

Defined in: src/execution/types.ts:164

Current immutable state snapshot


strategy: AgentStrategy

Defined in: src/execution/types.ts:168

Agent lifecycle hooks for observability and control


tools: Tool<unknown, unknown>[]

Defined in: src/execution/types.ts:166

Resolved tools available for this execution