Skip to content

Function: serializeTurnContext()

Makaio Framework


Makaio Framework / ai-adapters-core / serializeTurnContext

serializeTurnContext(turnContext): SerializedContextBlock[]

Defined in: ../../../adapters/core/src/utils/serializeTurnContext.ts:204

Serialize a MessageHandle’s turnContext into ordered text blocks.

All non-null, non-undefined keys are serialized. The skillCatalog, skills, and contextRules keys get dedicated markdown formatting; all other keys are JSON-serialized.

Each adapter converts these blocks to its wire format:

  • Claude SDK: each block → prependContextBlock(msg, tag, content)
  • Anthropic/OpenAI: join and prepend to user message
  • Gemini: push as requestPart
  • CLI/Copilot: prepend to prompt string
  • Codex: push as userInput

Record<string, JsonValue | undefined> | undefined

The context record from MessageHandle.turnContext

SerializedContextBlock[]

Ordered blocks: skillCatalog, skills, contextRules, then remaining keys alphabetical. Empty when turnContext is nullish or empty.