Repository navigation
Python: Keep tool arguments off invocation metrics - #9361
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The attribute separation is correct and regression coverage validates both successful and failed invocations.
0 open findings
What changed in this PR
Separates tool-span attributes from invocation-metric attributes to prevent sensitive tool payloads leaking into metric dimensions.
Changes:
- Creates independent span and metric attribute dictionaries.
- Preserves metric error classification.
- Adds success and failure regression coverage.
| File | Description |
|---|---|
python/packages/core/agent_framework/_tools.py |
Detaches metric attributes before span enrichment. |
python/packages/core/tests/core/test_tools.py |
Verifies arguments and results remain absent from metrics. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): 3c6058ecc884
Model: gpt-5.6-sol
Overview
The change takes a detached metric-attribute snapshot before enriching the function span with sensitive tool arguments, while continuing to write tool results directly to the span. Explicit error propagation preserves error.type on failed-invocation metrics, and the updated tests cover successful and failed calls while asserting that payloads stay off histogram attributes. No publishable Critical, High, or Medium regression was established.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Motivation & Context
A report in an email thread identified that
gen_ai.tool.call.argumentswas being attached to theagent_framework.function.invocation.durationmetric for Foundry-hosted Agent Framework agents. This exposed serialized tool inputs, including calculator expressions and complete questions passed to specialist agents, as metric dimensions even though the attribute is intended for tool-execution spans.The metric and span shared the same mutable attribute dictionary, allowing span-only payload attributes to flow into the histogram recording.
Description & Review Guide
error.typebehavior are preserved.Related Issue
N/A - trivial change. This was reported through an email thread rather than a GitHub issue; keeping span-only tool argument payloads off a duration metric is an obvious telemetry correction. No competing open PR was found.
AI Assistance
AI assistance details: Copilot assisted with the implementation, regression tests, and PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.