Class: AgentTurnExecutor
Makaio Framework / ai-adapters-core / AgentTurnExecutor
Class: AgentTurnExecutor
Section titled “Class: AgentTurnExecutor”Defined in: ../../../adapters/core/src/agent/agent-turn-executor.ts:51
Shared start/send-message execution pipeline for AIAgent.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AgentTurnExecutor(
config):AgentTurnExecutor
Defined in: ../../../adapters/core/src/agent/agent-turn-executor.ts:62
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”AgentTurnExecutor
Methods
Section titled “Methods”executeSendMessage()
Section titled “executeSendMessage()”executeSendMessage(
payload):Promise<{messageId:string; }>
Defined in: ../../../adapters/core/src/agent/agent-turn-executor.ts:79
Execute the turn pipeline for agent.sendMessage.
Parameters
Section titled “Parameters”payload
Section titled “payload”agent.sendMessage request payload
adapterId
Section titled “adapterId”string = ...
agentId
Section titled “agentId”string = ...
deliveryMode?
Section titled “deliveryMode?”"enqueue" | "immediate" = ...
message
Section titled “message”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
messageId?
Section titled “messageId?”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.
responseSchema?
Section titled “responseSchema?”Record<string, unknown> = ...
JSON Schema for structured output. When present and supported by the adapter, the model response is constrained to this schema.
sessionContext?
Section titled “sessionContext?”{ 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.
sessionContext.extractedContext?
Section titled “sessionContext.extractedContext?”unknown = ...
Structured context from compression (if hasCompression=true).
sessionContext.hasCompression?
Section titled “sessionContext.hasCompression?”boolean = ...
Whether compression is active (extractedContext present). If true, Agent should use fresh mode with compressed context.
sessionContext.hasConnectorSwap?
Section titled “sessionContext.hasConnectorSwap?”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.
sessionContext.hasNewTransforms?
Section titled “sessionContext.hasNewTransforms?”boolean = ...
Whether transforms have been applied since last turn. If true, Agent should use fresh mode (history changed).
sessionContext.isFirstTurn?
Section titled “sessionContext.isFirstTurn?”boolean = ...
Whether this is the first turn in the session. If true, no native history exists yet.
sessionContext.messageHistory?
Section titled “sessionContext.messageHistory?”object[] = ...
Curated message history assembled via getFullConversation(). Only used if Agent decides to inject (fresh mode).
sessionContext.turnContext?
Section titled “sessionContext.turnContext?”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().
sessionId?
Section titled “sessionId?”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.
turnId?
Section titled “turnId?”string = ...
Turn ID for correlation with session turns.
Returns
Section titled “Returns”Promise<{ messageId: string; }>
Resolved messageId from connector handle
executeStart()
Section titled “executeStart()”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.
Parameters
Section titled “Parameters”message
Section titled “message”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
options
Section titled “options”AgentSendMessageOptions | undefined
Start options from caller
systemPrompt
Section titled “systemPrompt”string | { content: string; mode: "append"; } | undefined
Runtime system prompt chosen by AIAgent
responseSchema?
Section titled “responseSchema?”Record<string, unknown>
Runtime response schema chosen by AIAgent
Returns
Section titled “Returns”Promise<AgentStartResult>
Agent start result from connector