runtime: emit metering events via public seam

This commit is contained in:
github-ops
2026-05-15 14:12:59 +00:00
parent 280ea99628
commit 42312ff76f
10 changed files with 270 additions and 19 deletions
+15
View File
@@ -710,6 +710,11 @@ async fn handle_base_tool_call(
.with_response_cache_scope(
tool.workspace_id.as_str().to_owned(),
tool.agent_id.as_str().to_owned(),
)
.with_metering_context(
tool.workspace_id.clone(),
Some(tool.agent_id.clone()),
InvocationSource::AgentToolCall,
);
let request_preview = build_request_preview(&state.runtime, &operation, &arguments);
let started_at = Instant::now();
@@ -825,6 +830,11 @@ async fn handle_session_start_call(
.with_response_cache_scope(
tool.workspace_id.as_str().to_owned(),
tool.agent_id.as_str().to_owned(),
)
.with_metering_context(
tool.workspace_id.clone(),
Some(tool.agent_id.clone()),
InvocationSource::AgentToolCall,
);
let request_preview = build_request_preview(&state.runtime, &runtime_operation, &arguments);
let started_at = Instant::now();
@@ -1256,6 +1266,11 @@ async fn handle_async_job_start_call(
.with_response_cache_scope(
tool.workspace_id.as_str().to_owned(),
tool.agent_id.as_str().to_owned(),
)
.with_metering_context(
tool.workspace_id.clone(),
Some(tool.agent_id.clone()),
InvocationSource::AgentToolCall,
);
let request_preview = build_request_preview(&state.runtime, &operation, &arguments);
let Some(streaming) = tool.operation.execution_config.streaming.as_ref() else {