Expand description
Record model and resolver outputs once; replay them without the network.
replay_session re-drives a
recorded Live session through the real control plane, but anything that
calls a model or a remote service out of band still runs for real:
- an LLM extractor;
- an async resolver behind a slot;
- a background agent.
A replay would then cost money, need credentials, and could answer
differently. A Tape closes that gap. While recording, every call’s
input and output are appended to it. While replaying, calls are answered
from it, in the order they were recorded, and nothing leaves the process.
TapedLlmwraps anyBaseLlm.TapedLlm::recordingpasses calls through and records them;TapedLlm::replayingneeds no inner model and no credentials.taped_resolverwraps a resolver’sfetchthe same way, forExtract::field_resolveandConversation::resolve_slot.
Calls are matched on their canonical JSON input: the request, or the resolver’s name and arguments. The same input recorded twice replays its two outputs in order. A replay that asks for something the tape does not hold fails loudly rather than calling out.
use std::sync::Arc;
use gemini_adk_rs::llm::{BaseLlm, LlmRequest, LlmResponse, MockLlm};
use gemini_adk_rs::tape::{MemoryTape, TapedLlm};
let tape = Arc::new(MemoryTape::new());
// Record against a real (here: scripted) model.
let live = TapedLlm::recording(MockLlm::script([LlmResponse::from_text("Paris")]), tape.clone());
live.generate(LlmRequest::from_text("Capital of France?")).await?;
// Replay with no model at all.
let offline = TapedLlm::replaying("gemini-2.5-flash", tape);
let reply = offline.generate(LlmRequest::from_text("Capital of France?")).await?;
assert_eq!(reply.text(), "Paris");Structs§
- File
Tape - A tape kept in a JSONL file, one
TapeEntryper line. - Memory
Tape - A tape held in memory.
- Tape
Entry - One recorded call: what went in and what came out.
- Taped
Llm - A
BaseLlmthat records its calls to aTapeor answers them from one. See the module docs.
Enums§
- Tape
Mode - Whether a
taped_resolverrecords calls or answers them from the tape.
Constants§
Traits§
- Tape
- Where recorded calls are kept.
Functions§
- canonical_
json - Canonical JSON for
value: object keys sorted, no whitespace. - taped_
resolver - Wrap a resolver’s
fetchso its calls are recorded on, or answered from,tape.