Skip to content

feat(runtime): add agent dimension to librefang_tool_execution_seconds (#6244)#6245

Merged
houko merged 2 commits into
mainfrom
fix/6244-histogram-agent-label
Jun 20, 2026
Merged

feat(runtime): add agent dimension to librefang_tool_execution_seconds (#6244)#6245
houko merged 2 commits into
mainfrom
fix/6244-histogram-agent-label

Conversation

@houko

@houko houko commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #6244. librefang_tool_execution_seconds (the per-tool latency histogram added in #6228 / #6233) carried only a tool label, while the sibling librefang_tool_call_total counter emitted from the same function already carries agent (#6226). So tool failures were attributable per agent but tool latency was not — on a host running many agents that share tools, the per-tool p95 was an unweighted blend across callers (a slow agent and a fast agent on the same tool were indistinguishable).

Change

record_tool_call_metric (crates/librefang-runtime/src/agent_loop/tool_call.rs) now emits the histogram with {agent, tool}. agent is sourced from the agent_id already in scope and sanitized + length-capped via the same sanitize_tool_label used for the counter, so cardinality stays bounded — agent×tool is lower than the counter's existing agent×tool×outcome×failure_type. Doc comment and the inline comment updated to match.

Verification

Updated test_record_tool_call_metric_emits_latency_histogram (tests/utilities.rs) to assert the histogram carries the agent label (agent=agent) alongside tool=histtool. cargo test -p librefang-runtime runs in CI.

Closes #6244.

#6244)

The per-tool latency histogram carried only a `tool` label, so per-tool p95 was an unweighted blend across every calling agent.
The sibling `librefang_tool_call_total` counter from the same function already carries `agent` (#6226), so tool failures were attributable per agent but tool latency was not.

Adds the `agent` label to the histogram, sourced from the `agent_id` already in scope and sanitized + length-capped via the same `sanitize_tool_label` used for the counter, so it now emits `{agent,tool}`.
Cardinality stays bounded (agent x tool, lower than the counter's agent x tool x outcome x failure_type).
Updates `test_record_tool_call_metric_emits_latency_histogram` to assert the agent label is present.
@github-actions github-actions Bot added size/S 10-49 lines changed area/docs Documentation and guides area/runtime Agent loop, LLM drivers, WASM sandbox labels Jun 20, 2026
Code comments must not reference the task/PR that introduced a change
— they rot as the codebase evolves and belong in the PR description.
Remove the "; agent dimension #6244" annotation appended to the
existing #6228 reference in the inline histogram comment.
@houko
houko enabled auto-merge (squash) June 20, 2026 01:19
@houko
houko merged commit f6898a5 into main Jun 20, 2026
31 checks passed
@houko
houko deleted the fix/6244-histogram-agent-label branch June 20, 2026 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Documentation and guides area/runtime Agent loop, LLM drivers, WASM sandbox size/S 10-49 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

librefang_tool_execution_seconds has no agent dimension — per-tool latency can't be attributed per-agent

2 participants