feat: memory usage metrics (#12120)

This commit is contained in:
jif-oai
2026-02-18 12:45:19 +00:00
committed by GitHub
Unverified
parent 2293ab0e21
commit a9f5f633b2
5 changed files with 129 additions and 4 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ mod request_user_input;
mod search_tool_bm25;
mod shell;
mod test_sync;
mod unified_exec;
pub(crate) mod unified_exec;
mod view_image;
pub use plan::PLAN_TOOL;
@@ -26,10 +26,10 @@ use std::sync::Arc;
pub struct UnifiedExecHandler;
#[derive(Debug, Deserialize)]
struct ExecCommandArgs {
pub(crate) struct ExecCommandArgs {
cmd: String,
#[serde(default)]
workdir: Option<String>,
pub(crate) workdir: Option<String>,
#[serde(default)]
shell: Option<String>,
#[serde(default = "default_login")]
@@ -238,7 +238,7 @@ impl ToolHandler for UnifiedExecHandler {
}
}
fn get_command(args: &ExecCommandArgs, session_shell: Arc<Shell>) -> Vec<String> {
pub(crate) fn get_command(args: &ExecCommandArgs, session_shell: Arc<Shell>) -> Vec<String> {
let model_shell = args.shell.as_ref().map(|shell_str| {
let mut shell = get_shell_by_model_provided_path(&PathBuf::from(shell_str));
shell.shell_snapshot = crate::shell::empty_shell_snapshot_receiver();
+2
View File
@@ -6,6 +6,7 @@ use std::time::Instant;
use crate::client_common::tools::ToolSpec;
use crate::features::Feature;
use crate::function_tool::FunctionCallError;
use crate::memories::usage::emit_metric_for_tool_read;
use crate::protocol::SandboxPolicy;
use crate::sandbox_tags::sandbox_tag;
use crate::tools::context::ToolInvocation;
@@ -173,6 +174,7 @@ impl ToolRegistry {
Ok((preview, success)) => (preview.clone(), *success),
Err(err) => (err.to_string(), false),
};
emit_metric_for_tool_read(&invocation, success).await;
let hook_abort_error = dispatch_after_tool_use_hook(AfterToolUseHookDispatch {
invocation: &invocation,
output_preview,