Skip to content

Class: AgentTurnExecutor

Makaio Framework


Makaio Framework / ai-adapters-core / AgentTurnExecutor

Defined in: ../../../adapters/core/src/agent/agent-turn-executor.ts:51

Shared start/send-message execution pipeline for AIAgent.

new AgentTurnExecutor(config): AgentTurnExecutor

Defined in: ../../../adapters/core/src/agent/agent-turn-executor.ts:62

AgentTurnExecutorConfig

AgentTurnExecutor

executeSendMessage(payload): Promise<{ messageId: string; }>

Defined in: ../../../adapters/core/src/agent/agent-turn-executor.ts:79

Execute the turn pipeline for agent.sendMessage.

agent.sendMessage request payload

string = ...

string = ...

"enqueue" | "immediate" = ...

string | { blocks: { content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; } | ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; role?: "user" | "assistant" | "system"; } = MessageInputSchema

string = ...

Message ID from orchestrator. If provided, this ID flows through the entire processing chain, enabling correlation between user messages and agent responses. If omitted, the adapter generates its own ID.

Record<string, unknown> = ...

JSON Schema for structured output. When present and supported by the adapter, the model response is constrained to this schema.

{ extractedContext?: unknown; hasCompression?: boolean; hasConnectorSwap?: boolean; hasNewTransforms?: boolean; isFirstTurn?: boolean; messageHistory?: object[]; turnContext?: Record<string, unknown>; } = ...

Session context with curated messageHistory and decision signals. Contains curated messageHistory and flags for native resume decision.

unknown = ...

Structured context from compression (if hasCompression=true).

boolean = ...

Whether compression is active (extractedContext present). If true, Agent should use fresh mode with compressed context.

boolean = ...

Whether a connector swap occurred before this message (e.g., cwd/model change). If true, native resume is infeasible and adapters should use fresh mode.

boolean = ...

Whether transforms have been applied since last turn. If true, Agent should use fresh mode (history changed).

boolean = ...

Whether this is the first turn in the session. If true, no native history exists yet.

object[] = ...

Curated message history assembled via getFullConversation(). Only used if Agent decides to inject (fresh mode).

Record<string, unknown> = ...

Turn-scoped context assembled by PreUserMessage hooks and the orchestrator. Keys are plugin-defined (e.g., ‘skillCatalog’, ‘skills’, ‘predictedTools’). Adapters consume this to prepend context blocks.

Constrained to JSON-safe types to ensure serialization succeeds.

ADAPTER CONTRACT: Every adapter MUST materialize turnContext into the LLM-facing message using serializeTurnContext().

string = ...

Session ID for hook context enrichment. Enables PreUserMessage hooks to look up session, history, and project. Optional for backwards compatibility - hooks work without it but return empty enrichments.

string = ...

Turn ID for correlation with session turns.

Promise<{ messageId: string; }>

Resolved messageId from connector handle


executeStart(message, options, systemPrompt, responseSchema?): Promise<AgentStartResult>

Defined in: ../../../adapters/core/src/agent/agent-turn-executor.ts:118

Execute the turn pipeline for agent.start.

string | { blocks: { content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; } | ({ content: string; type: "text"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "image"; } | { source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "document"; } | { attachmentType: "file" | "directory"; displayName?: string; fileName: string; filePath: string; source: { data: string; mimeType: string; type: "base64"; } | { mimeType?: string; type: "url"; url: string; }; type: "attachment"; } | { content: string; metadata?: Record<string, unknown>; type: "reasoning"; } | { args: Record<string, unknown>; name: string; toolCallId: string; type: "tool_call"; } | { isError?: boolean; output: string; toolCallId: string; type: "tool_output"; })[]; role?: "user" | "assistant" | "system"; } | NormalizedMessageInput

Initial message payload

AgentSendMessageOptions | undefined

Start options from caller

string | { content: string; mode: "append"; } | undefined

Runtime system prompt chosen by AIAgent

Record<string, unknown>

Runtime response schema chosen by AIAgent

Promise<AgentStartResult>

Agent start result from connector