Skip to main content

Function: ensureToolResultsExist()

ensureToolResultsExist(messages): ChatMessage[]

Defined in: core/dist/types/segments/derivation.d.ts:32

Ensure all tool calls have corresponding results. Injects synthetic error results for any orphaned tool calls. This is required by LLM APIs (Anthropic, OpenAI) which expect every tool_use to have a matching tool_result.

Parameters

messages

ChatMessage[]

Returns

ChatMessage[]