pub struct RecordingLlmClient { /* private fields */ }Expand description
A transparent InferenceAdapter that records each turn into a shared transcript.
Why: Captures the conversation for the run report without modifying the agent
loop. Wrapping the shared client means PM and engineer turns land in one
ordered transcript while usage still accrues on the inner client.
What: Forwards chat to the inner client, then appends a TurnRecord tagged
with this wrapper’s role and the request’s model. A poisoned transcript
lock is treated as a no-op record (the run must not panic mid-flight).
Test: run_task::tests::end_to_end_pm_delegates_to_engineer.
Clone is cheap (an Arc, a String, and an Arc) and exists so
Self::chat_stream’s 'static stream closure can carry the recorder’s
transcript handle past the borrow of &self (#4425).
Implementations§
Source§impl RecordingLlmClient
impl RecordingLlmClient
Sourcepub fn new(
inner: Arc<dyn InferenceAdapter>,
role: impl Into<String>,
transcript: SharedTranscript,
) -> Self
pub fn new( inner: Arc<dyn InferenceAdapter>, role: impl Into<String>, transcript: SharedTranscript, ) -> Self
Wrap inner, tagging recorded turns with role.
Why: Each agent (PM, engineer) needs its own labelled recorder sharing the
same transcript sink so the report can distinguish their turns.
What: Stores the inner client, the role label, and the shared transcript.
Test: run_task::tests::end_to_end_pm_delegates_to_engineer.
Trait Implementations§
Source§impl Clone for RecordingLlmClient
impl Clone for RecordingLlmClient
Source§impl InferenceAdapter for RecordingLlmClient
impl InferenceAdapter for RecordingLlmClient
Source§fn chat<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, InferenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn chat<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, InferenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Forward the chat call and record the resulting turn.
Why: The transcript must reflect exactly what the model returned; recording
after the call (on success) keeps the report faithful and never fabricates
turns for failed requests.
What: Calls the inner client; on Ok, appends a TurnRecord with the
RESOLVED model slug (#1475 bug 2 — resp.resolved_model(&req.model),
which prefers the provider-reported model and falls back to the
requested slug when the response omits one), the response’s first
text, its tool-call names, and (#2279) whether any of those calls was
a matching bash test invocation (ran_test_command, computed via
crate::verify_gate::bash_command_from_call +
crate::verify_gate::is_test_command — the SAME predicate the
engineer’s own in-transcript gate uses); returns the response
unchanged. Errors propagate untouched (and are not recorded).
Test: run_task::tests::end_to_end_pm_delegates_to_engineer,
run_task::tests::transcript_records_resolved_model_not_requested_slug,
run_task::tests::recorder_flags_ran_test_command_on_matching_bash_call.
Source§fn chat_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatStream, InferenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn chat_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatStream, InferenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Forward the STREAMING chat call, recording the turn once it completes.
Why (#4425): without this override the trait’s default would buffer via
Self::chat — and since run_task and task::executor wrap EVERY
production client in this recorder, inheriting the default would have
silently disabled streaming on exactly the paths that matter, leaving
streaming working only in tests. The transcript must still be recorded,
which is why this wraps the stream rather than merely forwarding it.
What: delegates to the inner adapter’s chat_stream, then re-emits every
event unchanged while folding it into a StreamAssembly; when the
stream ends the assembled turn is recorded exactly as the blocking path
records it. A stream dropped early (cancellation) records nothing —
matching chat, which records nothing on error. One difference is
inherent to the wire: a streamed turn carries no resolved-model field
(the SSE terminal event reports finish reason + usage only), so the
recorded model is the REQUESTED slug — the same value
crate::llm::resolved_model falls back to whenever a provider omits
it, so the record’s shape is unchanged.
Test: run_task::tests cover the blocking path;
crate::agent_loop::tests::sink_events covers the streamed path.
Source§fn capabilities(&self) -> &ProviderCapabilities
fn capabilities(&self) -> &ProviderCapabilities
Source§fn capabilities_for(&self, model: &str) -> &ProviderCapabilities
fn capabilities_for(&self, model: &str) -> &ProviderCapabilities
model. Read moreSource§fn map_tool_choice(&self, choice: ToolChoice) -> Value
fn map_tool_choice(&self, choice: ToolChoice) -> Value
ToolChoice into this provider’s wire JSON. Read moreSource§fn supports_native_tools(&self) -> bool
fn supports_native_tools(&self) -> bool
Source§fn supports_prompt_caching(&self) -> bool
fn supports_prompt_caching(&self) -> bool
Source§fn supports_structured_output(&self) -> bool
fn supports_structured_output(&self) -> bool
Source§fn ensure_structured_output_supported(
&self,
request: &ChatRequest,
) -> Result<(), InferenceError>
fn ensure_structured_output_supported( &self, request: &ChatRequest, ) -> Result<(), InferenceError>
Source§fn wants_detailed_usage(&self) -> bool
fn wants_detailed_usage(&self) -> bool
usage: {"include": true} directive). Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RecordingLlmClient
impl !UnwindSafe for RecordingLlmClient
impl Freeze for RecordingLlmClient
impl Send for RecordingLlmClient
impl Sync for RecordingLlmClient
impl Unpin for RecordingLlmClient
impl UnsafeUnpin for RecordingLlmClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more