Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/agentsight/src/bin/cli/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ pub struct TraceCommand {
#[structopt(long)]
pub enable_filewatch: bool,

/// Enable the observe-only LLM cache-hit shadow analyzer (measures would-be
/// cache hits and key precision on real traffic; never serves)
#[structopt(long)]
pub enable_cache_analysis: bool,

/// Path to JSON configuration file
#[structopt(short, long, default_value = "/etc/agentsight/config.json")]
pub config: String,
Expand Down Expand Up @@ -72,6 +77,7 @@ impl TraceCommand {
let config = AgentsightConfig::new()
.set_verbose(self.verbose)
.set_enable_filewatch(self.enable_filewatch)
.set_enable_cache_analysis(self.enable_cache_analysis)
.set_config_path(std::path::PathBuf::from(&self.config));

// Create AgentSight (auto-attaches probes and starts polling)
Expand Down
10 changes: 10 additions & 0 deletions src/agentsight/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ pub struct AgentsightConfig {
/// Obtain via `stat -c %i /sys/fs/cgroup/<path>` (v2) or
/// `stat -c %i /sys/fs/cgroup/memory/<path>` (v1).
pub cgroup_ids: Vec<u64>,
/// Enable the observe-only LLM cache-hit shadow analyzer (measures would-be
/// cache hits + key precision on real traffic; never serves).
pub enable_cache_analysis: bool,
/// TCP capture targets for plain HTTP capture (empty = disabled).
/// Each entry specifies destination IP, port, or both.
pub tcp_targets: Vec<TcpTarget>,
Expand Down Expand Up @@ -525,6 +528,7 @@ impl Default for AgentsightConfig {
enable_filewatch: false,
cgroup_filter_enabled: false,
cgroup_ids: Vec::new(),
enable_cache_analysis: false,
tcp_targets: Vec::new(),

// HTTP/Aggregation defaults
Expand Down Expand Up @@ -630,6 +634,12 @@ impl AgentsightConfig {
self
}

/// Set enable_cache_analysis
pub fn set_enable_cache_analysis(mut self, enable: bool) -> Self {
self.enable_cache_analysis = enable;
self
}

/// Set connection capacity
pub fn set_connection_capacity(mut self, capacity: usize) -> Self {
self.connection_capacity = capacity;
Expand Down
2 changes: 1 addition & 1 deletion src/agentsight/src/genai/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ impl GenAIBuilder {
///
/// [Tue 2026-03-31 17:19 GMT+8] 用户实际输入
/// ```
fn strip_user_query_prefix(text: &str) -> String {
pub(crate) fn strip_user_query_prefix(text: &str) -> String {
// 查找最后一个 [timestamp] 模式,取其后的内容
// 格式: [Day YYYY-MM-DD HH:MM TZ] 或 [Day, DD Mon YYYY HH:MM:SS TZ]
if let Some(pos) = text.rfind(']') {
Expand Down
Loading
Loading