Skip to main content

create_react_agent_with_recording

Function create_react_agent_with_recording 

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

Build a prebuilt ReAct agent graph that journals every model and tool call into journal (Flight Recorder, R0.5).

Identical to create_react_agent in topology and behavior; the only delta is evidence: the agent node wraps the model in crate::replay::RecordingChatModel and the tools node wraps each dispatched tool in crate::replay::RecordingTool, so the journal gains model_call / tool_call events in the canonical crate::replay::model_call_request / crate::replay::tool_call_request shapes. Each event’s causal parent is the invocation’s node-input event (PARENT_EVENT_KEY), so iteration N’s model call hangs off iteration N’s agent input, and each tool call off its tools input.

Attach the same journal to the run (crate::executor::RunConfig::with_journal) so node and executor evidence share one journal; for a byte-identical replay later, record under the determinism seams (crate::journal::Clock::logical + crate::journal::RngSource::seeded). Replay the recorded run with create_react_agent_replaying under crate::replay::ExactReplay.

There is deliberately no streaming recording flavor: the streaming variant’s token forwarding is a live-observability concern, and the recording wrappers record through ChatModel::chat.