Skip to main content

Module testing

Module testing 

Source
Expand description

Testing utilities for the managed agent runtime.

This module provides deterministic test doubles for the managed agent runtime pipeline. These are not mocks — they implement the real traits and exercise the full runtime pipeline (parking, checkpoints, replay, event mapping). Only the LLM provider API call is replaced with pre-scripted deterministic responses.

§Architecture

ScriptedLlm (deterministic responses)
  │
  ▼
Full runtime pipeline (SessionLoop, CheckpointManager, ToolParkingLot, etc.)
  │
  ▼
SessionEvent stream (byte-identical assertions possible)

§Usage

use adk_managed::testing::{ScriptedLlm, ScriptedTurn, ScriptedToolCall};
use serde_json::json;

let turns = vec![
    ScriptedTurn {
        text: Some("Hello! How can I help you?".to_string()),
        tool_calls: vec![],
    },
    ScriptedTurn {
        text: None,
        tool_calls: vec![ScriptedToolCall {
            name: "web_search".to_string(),
            input: json!({"query": "rust async"}),
            id: Some("tc_001".to_string()),
        }],
    },
];

let llm = ScriptedLlm::new("scripted-model", turns);
// Use llm in place of any Arc<dyn Llm> in the runtime pipeline

Structs§

ScriptedLlm
A deterministic LLM double with pre-scripted responses.
ScriptedToolCall
A scripted tool call within a ScriptedTurn.
ScriptedTurn
A pre-scripted turn that the ScriptedLlm will return.