ToolResultContract

org.llm4s.testkit.ToolResultContract

The tool-result contract (design ยง5.3 of the typed agent runtime): every tool call a request carries has exactly one result, straight after the message that made it, in the provider's own format - and no result answers a call that is not there. OpenAI rejects a request that breaks it; Anthropic rejects one too, which is why an Anthropic client must never be handed such a conversation, rather than drop or rewrite what does not pair.

violations reads a request body; cases are the conversations an agent's tool loop sends after every outcome of a call - success, a tool error, a rejection or denial, an unknown tool, a refused handoff batch, a handoff - including provider call ids reused across turns. ProviderModuleChecks.assertOneToolResultPerCall sends each case through a client and checks what reaches the server.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def toolCallCount(format: ToolMessageFormat, requestBody: Value): Int

The tool calls requestBody carries in format.

The tool calls requestBody carries in format.

Attributes

def toolResultCount(format: ToolMessageFormat, requestBody: Value): Int

The native tool results requestBody carries in format (a result sent as text is not one).

The native tool results requestBody carries in format (a result sent as text is not one).

Attributes

def violations(format: ToolMessageFormat, requestBody: Value): Vector[String]

Every way requestBody breaks the contract in format, in message order; empty when it holds.

Every way requestBody breaks the contract in format, in message order; empty when it holds.

Attributes

Concrete fields

val cases: Vector[ToolResultCase]

The conversations the contract sends, each a valid conversation that ends where the next model call begins. Error results carry {"error": ...}, as the agent's tool loop writes them.

The conversations the contract sends, each a valid conversation that ends where the next model call begins. Error results carry {"error": ...}, as the agent's tool loop writes them.

Attributes