@langwatch/scenario
    Preparing search index...

    Function toModelMessages

    • Converts the inner messages of a stream-json transcript into AI SDK model messages, the format @langwatch/scenario works with.

      Claude Code writes Anthropic-format messages: an assistant turn is an array of thinking, text and tool_use blocks, and each tool result comes back as a user message holding tool_result blocks. Each assistant turn becomes one text part (the text blocks joined, an empty string when the turn only called tools) followed by one tool-call part per tool_use block. Each tool_result block becomes a tool-result part of a tool message, with the tool name looked up from the call it answers. Thinking blocks are dropped. A block of any other type leaves a line naming it.

      Parameters

      • rawMessages: ClaudeStreamInnerMessage[]
      • limits: TranscriptLimits = DEFAULT_TRANSCRIPT_LIMITS

      Returns ModelMessage[]