Available on crate feature
test-utils only.Expand description
Test utilities for the classic runtime and its provider-facing acceptance tests.
Structs§
- Append
Failing Memory - Memory backend that loads empty history and always fails on append.
- Barrier
Mock Tool Index - A vector index that waits at a barrier before returning one tool ID.
- Captured
Http Request - Request data captured by
RecordingHttpClient. - Conformance
Tool Error - Error used by the deterministic conformance tools.
- Counting
Memory - Memory backend that records load and append calls while delegating storage to
InMemoryConversationMemory. - Failing
Memory - Memory backend that always fails on load and no-ops append and clear.
- Http
Error Streaming Client - An
HttpClientExtimplementation whosesend_streamingfails immediately with a non-success HTTP status and response body. - Mock
AddTool - A mock tool that adds
xandy. - Mock
Barrier Tool - A mock tool that waits at a barrier before returning
"done". - Mock
Completion Model - A cloneable scripted
CompletionModelfor tests. - Mock
Context Probe Tool - A mock tool that records whatever it observed in its per-call
ToolContext, so tests can assert the context reached tool execution. - Mock
Controlled Tool - A mock tool that notifies when started and waits for an explicit finish signal.
- Mock
Denied Tool - A tool that refuses execution, distinct from a framework policy skip.
- Mock
Embedding Model - A deterministic
EmbeddingModelthat returns a fixed vector for each input document. - Mock
Example Tool - A mock tool named
example_toolthat returns"Example answer". - Mock
Failing Tool - A tool that always fails with a configured
ToolErrorKind. Used to exercise structured tool-failure surfacing (timeout, not-found, rate-limited, …) without a live provider. Registered under the nameflaky_tool. - Mock
Failure - Error type for
MockFailingTool, carrying a fixed message. - Mock
Handled Failure Tool - A tool failure with separate operator and model-visible feedback.
- Mock
Image Generator Tool - A mock tool named
generate_test_imagethat returns a 1x1 red PNG image payload. - Mock
Image Output Tool - A mock tool that returns explicit image content.
- Mock
Metadata Tool - A tool whose success carries a
MockRequestIdin its result metadata. Registered under the namewith_meta. - Mock
Model Lister - A
ModelListerthat returns a preconfigured list of models. - Mock
Multi Text Document - A test document that contributes multiple text fragments to an embedding request.
- Mock
Object Output Tool - A mock tool that returns a JSON object.
- Mock
Operation Args - Arguments for arithmetic mock tools.
- Mock
Request Id - Cloneable metadata a
MockMetadataToolattaches to its result, used to verify that result metadata reaches hooks without being sent to the model. - Mock
Response - Raw mock response used by completion and streaming test utilities.
- Mock
Streaming Client - A mock HTTP client that returns pre-built SSE bytes from
send_streaming. - Mock
String Output Tool - A mock tool that returns a multiline string.
- Mock
Subtract Tool - A mock tool that subtracts
yfromx. - Mock
Text Document - A test document that contributes one text fragment to an embedding request.
- Mock
Tool Error - Shared error type for mock tools.
- Mock
Tool Index - A vector index that returns a predefined list of tool IDs from
top_n_ids. - Mock
Turn - A scripted non-streaming mock completion turn.
- Recording
Http Client - An
HttpClientExtimplementation that records unary requests and returns a fixed response. - Scenario
Report - Summary emitted by a portable model-conformance scenario.
- Sequenced
Http Client - An
HttpClientExtimplementation that records unary requests and returns one scripted response per request. - Sequenced
Streaming Http Client - An
HttpClientExtimplementation that returns one scripted stream of byte chunks fromsend_streaming. - Session
Id - A caller-injected context value, like a session id or auth token carried in
a
ToolContext.
Enums§
- Mock
Error - Scripted error returned by
MockCompletionModel. - Mock
Http Response - Response scripted for
RecordingHttpClient. - Mock
Stream Event - Scripted streaming event yielded by
MockCompletionModel. - Scenario
Error - Typed failure from a portable model-conformance scenario.
Functions§
- buffered_
streaming_ text_ parity - Runs the same deterministic text request through buffered and raw streaming completion surfaces and validates equivalent visible content and usage.
- cancellation_
and_ max_ turns - Exercises post-execution cancellation and max-turn diagnostics through the public agent driver using real model-emitted calls.
- complex_
tool_ arguments - Runs a nested, escaped, Unicode-bearing argument payload through typed tool deserialization and validates the exact semantic value received by the tool.
- decode_
structured_ output - Decode a structured-output response with a typed conformance failure that retains the scenario name and raw response.
- hook_
rewrites_ and_ request_ patch - Exercises chained argument/result rewrites and a first-turn-only request
patch. Completion proves
tool_choice=Requireddid not leak to turn two. - invalid_
tool_ recovery - Uses one real model turn to exercise fail-fast, retry exhaustion, repair, rejected repair, and skip handling without executing a disallowed call.
- mock_
math_ toolset - Create a
ToolSetcontainingMockAddToolandMockSubtractTool. - optional_
argument - Runs the portable optional-argument tool scenario.
- parallel_
tools - Runs two independent calls in one assistant turn and validates canonical call/result history correlation.
- scoped_
tracing_ subscriber_ guard - Serializes tests that install scoped tracing subscribers
(
tracing::subscriber::set_default/with_default). - scoped_
tracing_ subscriber_ guard_ blocking - Blocking variant of
scoped_tracing_subscriber_guardfor synchronous tests. - sequential_
tools - Runs a portable two-tool sequential arithmetic scenario.
- streaming_
structured_ after_ tool - Runs a streamed real-tool turn followed by Rig’s synthetic output tool.
- streaming_
tool - Runs a tool through Rig’s multi-turn streaming agent driver.
- structured_
after_ tool - Runs a normal tool followed by Rig’s synthetic structured-output tool.
- structured_
extraction - Runs Rig’s structured extractor and validates both the extracted semantic fields and accumulated usage.
- tool_
choice_ modes - Runs all portable tool-choice modes directly against a completion model.
- tool_
output_ serialization - Runs string- and JSON-returning tools and validates that neither output is double encoded.
- validate_
cancelled_ failure - Validate cancellation diagnostics, including the exact reason and retained assistant tool-call history.
- validate_
extraction_ fields - Validate a provider-neutral person extraction and its usage accounting.
- validate_
max_ turns_ failure - Validate max-turn diagnostics, including the exact configured budget and a retained pending prompt.
- validate_
protocol_ hygiene - Validate that model-family control markers are absent from user-visible output and persisted history.
- validate_
result_ redaction - Validate that a sensitive raw tool result was produced but did not reach the model’s user-visible response after result hooks ran.
- validate_
rewritten_ arguments - Validate that every observed tool invocation contains the expected rewritten argument fields while allowing unrelated original fields to remain.
- validate_
unknown_ tool_ failure - Validate the portable diagnostics carried by an unknown or disallowed tool call failure.
- zero_
argument_ tool - Runs a zero-argument tool and validates verbatim string-result handling.