Skip to main content

create_react_agent_replaying

Function create_react_agent_replaying 

Source
pub fn create_react_agent_replaying(
    model: Arc<dyn ChatModel>,
    tools: ToolRegistry,
    source: ReplaySource,
    journal: Journal,
) -> Result<Graph>
Expand description

Build a prebuilt ReAct agent graph that answers every model and tool call from a recorded journal instead of executing it (exact replay).

The replaying analogue of create_react_agent_with_recording: same topology, but the nodes wrap model and tools in crate::replay::ReplayingChatModel / crate::replay::ReplayingTool, which serve each call from source (matched by sequence + canonical request hash) and re-journal it into journal. The wrapped model and tools are never invoked — carry them for their identity (effect class, tool schemas) and pass panic-on-call sentinels to prove the zero-outbound guarantee. The registry must offer the same tool identities (name, description, parameter schema) as the recorded run’s: schema content feeds the model-call request hash.

Build source and journal from an crate::replay::ExactReplay session (source() / fresh_journal()) and drive the graph via crate::replay::ExactReplay::run_and_verify; see examples/react_record_replay.rs.