|
@@ -1,7 +1,6 @@
|
|
|
use std::collections::BTreeMap;
|
|
use std::collections::BTreeMap;
|
|
|
use std::fmt::{Display, Formatter};
|
|
use std::fmt::{Display, Formatter};
|
|
|
|
|
|
|
|
-use serde_json::{Map, Value};
|
|
|
|
|
use telemetry::SessionTracer;
|
|
use telemetry::SessionTracer;
|
|
|
|
|
|
|
|
use crate::compact::{
|
|
use crate::compact::{
|
|
@@ -114,6 +113,7 @@ pub struct ConversationRuntime<C, T> {
|
|
|
auto_compaction_input_tokens_threshold: u32,
|
|
auto_compaction_input_tokens_threshold: u32,
|
|
|
hook_abort_signal: HookAbortSignal,
|
|
hook_abort_signal: HookAbortSignal,
|
|
|
hook_progress_reporter: Option<Box<dyn HookProgressReporter>>,
|
|
hook_progress_reporter: Option<Box<dyn HookProgressReporter>>,
|
|
|
|
|
+ session_tracer: Option<SessionTracer>,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl<C, T> ConversationRuntime<C, T>
|
|
impl<C, T> ConversationRuntime<C, T>
|
|
@@ -162,6 +162,7 @@ where
|
|
|
auto_compaction_input_tokens_threshold: auto_compaction_threshold_from_env(),
|
|
auto_compaction_input_tokens_threshold: auto_compaction_threshold_from_env(),
|
|
|
hook_abort_signal: HookAbortSignal::default(),
|
|
hook_abort_signal: HookAbortSignal::default(),
|
|
|
hook_progress_reporter: None,
|
|
hook_progress_reporter: None,
|
|
|
|
|
+ session_tracer: None,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -192,6 +193,12 @@ where
|
|
|
self
|
|
self
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ #[must_use]
|
|
|
|
|
+ pub fn with_session_tracer(mut self, session_tracer: SessionTracer) -> Self {
|
|
|
|
|
+ self.session_tracer = Some(session_tracer);
|
|
|
|
|
+ self
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
fn run_pre_tool_use_hook(&mut self, tool_name: &str, input: &str) -> HookRunResult {
|
|
fn run_pre_tool_use_hook(&mut self, tool_name: &str, input: &str) -> HookRunResult {
|
|
|
if let Some(reporter) = self.hook_progress_reporter.as_mut() {
|
|
if let Some(reporter) = self.hook_progress_reporter.as_mut() {
|
|
|
self.hook_runner.run_pre_tool_use_with_context(
|
|
self.hook_runner.run_pre_tool_use_with_context(
|
|
@@ -272,7 +279,7 @@ where
|
|
|
let user_input = user_input.into();
|
|
let user_input = user_input.into();
|
|
|
self.record_turn_started(&user_input);
|
|
self.record_turn_started(&user_input);
|
|
|
self.session
|
|
self.session
|
|
|
- .push_user_text(user_input.into())
|
|
|
|
|
|
|
+ .push_user_text(user_input)
|
|
|
.map_err(|error| RuntimeError::new(error.to_string()))?;
|
|
.map_err(|error| RuntimeError::new(error.to_string()))?;
|
|
|
|
|
|
|
|
let mut assistant_messages = Vec::new();
|
|
let mut assistant_messages = Vec::new();
|
|
@@ -488,6 +495,24 @@ where
|
|
|
removed_message_count: result.removed_message_count,
|
|
removed_message_count: result.removed_message_count,
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ fn record_turn_started(&self, _user_input: &str) {}
|
|
|
|
|
+
|
|
|
|
|
+ fn record_assistant_iteration(
|
|
|
|
|
+ &self,
|
|
|
|
|
+ _iteration: usize,
|
|
|
|
|
+ _assistant_message: &ConversationMessage,
|
|
|
|
|
+ _pending_tool_use_count: usize,
|
|
|
|
|
+ ) {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fn record_tool_started(&self, _iteration: usize, _tool_name: &str) {}
|
|
|
|
|
+
|
|
|
|
|
+ fn record_tool_finished(&self, _iteration: usize, _result_message: &ConversationMessage) {}
|
|
|
|
|
+
|
|
|
|
|
+ fn record_turn_completed(&self, _summary: &TurnSummary) {}
|
|
|
|
|
+
|
|
|
|
|
+ fn record_turn_failed(&self, _iteration: usize, _error: &RuntimeError) {}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[must_use]
|
|
#[must_use]
|