Expand description
Tool loop - deterministic multi-turn fake-tool conformance harness
(feedback 02, suite 40-multi-turn-tool-loop).
This is the most important Hermes test: a LIVE model must complete a three-step fixture workflow through OpenAI-format tool calls backed by deterministic in-memory fake tools - no filesystem, terminal, or network side effects beyond the one chat-completions POST per assistant turn:
read_fixture- the runner returns the fixture source;run_fixture_test- the runner returns a CONTROLLED failure report;write_fixture_patch- the runner returns a success report;- the model delivers a concise final answer with no tool calls.
Acceptance (feedback 02): correct ordering (read before run before
write; re-reading after a successful run is a violation), no invalid tool
names, all argument JSON valid and schema-conformant, no duplicate call
of the same tool with identical arguments after a successful result, a
final answer, and at most TOOL_LOOP_MAX_TURNS turns. Every violation
maps to exactly one FailureClass: a first turn with no tool calls is
FailureClass::NoToolCall, an unknown tool name is
FailureClass::InvalidToolName, unparseable or schema-violating
arguments are FailureClass::InvalidToolArguments, a repeated
(name + identical arguments) call is FailureClass::DuplicateToolCall,
and an incomplete or mis-ordered workflow (including a final answer that
skips part of the workflow) or a turn-budget breach is
FailureClass::ToolLoopDidNotConverge.
Cost gate: the live loop is opt-in. run_tool_loop refuses with
CloudflareError::MissingEnv naming AUTH_CLOUDFLARE_LIVE_TESTS
unless live_tests_enabled is true, so CI and unit tests can never
trigger a paid call by accident.
Security contract: ToolLoopOutcome carries only tool-call
observations (name + arguments + turn) and a truncated final answer -
never tool outputs, never prompts, never the token. The Authorization
header is built exclusively through crate::fetch::auth_header, and
every error string is token-scrubbed before it is returned.
Structs§
- Tool
Call Observation - One observed tool call from one assistant turn (serialized snake_case).
- Tool
Loop Outcome - Outcome of one tool-loop run.
Constants§
- LIVE_
TESTS_ ENV - Environment variable gating the LIVE tool-loop harness. Must equal
exactly
"1"forrun_tool_loopto run; anything else (unset,"0","yes", whitespace) refuses withCloudflareError::MissingEnv. - TOOL_
LOOP_ MAX_ TURNS - Maximum assistant turns allowed for one tool-loop run (feedback 02: “total turns ≤ 8”). A final answer ON the max turn is within budget; tool calls on the max turn are a breach.
- TOOL_
LOOP_ SYSTEM_ PROMPT - System prompt for the tool-loop harness (fixed fixture - never derived from user input, so it can never carry secrets).
- TOOL_
LOOP_ USER_ PROMPT - User prompt for the tool-loop harness: names the deterministic target
fixture so the enum-constrained
fixture_idargument is unambiguous.
Functions§
- all_
arguments_ valid - Argument acceptance: every call’s arguments must parse as a JSON object
and satisfy the tool’s schema - required fields present, correct types,
enum values respected, and no extra properties (
additionalProperties: false). Unknown tool names fail (no schema exists for them). Pure and hand-rolled: nojsonschemadependency. - execute_
tool - Execute one fake tool in memory. Deterministic per (tool, arguments); never touches the filesystem, terminal, or network.
- find_
duplicates - Duplicate acceptance: references to every call whose (name, identical
arguments) pair was already issued earlier in the sequence - including a
repeated
run_fixture_testafter a successful run, and a re-read of the same fixture. Argument equality is content-based (JSON object key order does not matter). - fixture_
source - The fixture source for a known fixture id, if any (deterministic, in-memory only).
- live_
tests_ enabled - True when the live harness is allowed to run:
AUTH_CLOUDFLARE_LIVE_TESTSmust equal exactly"1"(no trimming, no aliases). Shared with the siblingverify.rsintegration runner via the crate root. - run_
tool_ loop - Run the LIVE multi-turn tool-loop conformance suite for one model.
- tool_
schemas - The three OpenAI-format fake-tool schemas, built from [
TOOL_SPECS]. - validate_
ordering - Ordering acceptance: the full read → run → write workflow must appear in that order, with no re-read after a run and no run after a write.