Repository navigation
Keep tool and agent names on GenAI semconv execute_tool and invoke_agent spans - #26394
Conversation
…_agent` spans
The GenAI semconv translator renamed TOOL and AGENT spans to the bare
operation and dropped the `mlflow.*` attributes, so the exported span no
longer said which tool or agent ran.
Set `gen_ai.tool.name` and `gen_ai.agent.name` from the span name, keeping
the value when an instrumentation such as Strands or Semantic Kernel already
set it, and name the spans `execute_tool {name}` and `invoke_agent {name}`.
Signed-off-by: Christopher Krah <[email protected]>
Install mlflow from this PR
Install mlflow from this PR# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/26394/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/26394/merge#subdirectory=libs/skinnyFor Databricks, use the following command: %sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/26394/mergePR author's recent activityIn the last 14 days, @chrikrah opened 28 PRs across 14 repos (showing top 10):
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Existing names set through MLflow’s attribute API retain JSON quotation marks in exported attributes and span names.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Updates GenAI semantic-convention exports to retain tool and agent names.
Changes:
- Adds tool and agent semantic-convention keys.
- Derives span names and attributes from existing names.
- Adds translator coverage for tool and agent spans.
| File | Description |
|---|---|
mlflow/tracing/constant.py |
Adds tool and agent name keys. |
mlflow/tracing/export/genai_semconv/translator.py |
Preserves names during translation. |
tests/tracing/export/genai_semconv/test_translator.py |
Tests the updated translation behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
MLflow span APIs JSON-serialize attribute values, so a `gen_ai.tool.name` or `gen_ai.agent.name` set via `span.set_attribute` was exported with literal quotes, e.g. `invoke_agent "travel_planner"`. Decode the value when it is a JSON string and keep raw strings set directly on the OTel span as-is. Co-Authored-By: Claude <[email protected]> Signed-off-by: Aaron Teo <[email protected]>
|
@chrikrah invoke_agent Agent.run is fine for this PR. An existing gen_ai.agent.name / gen_ai.tool.name already takes precedence, so autologgers can set the real name in as follow-up changes. |
aaronteo-db
left a comment
There was a problem hiding this comment.
lgtm! thanks for your contribution
|
Documentation preview for 66ec608 is available at: More info
|

Related Issues/PRs
Closes #26316
What changes are proposed in this pull request?
_build_genai_span_name(translator.py:173-175) named TOOL and AGENT spansexecute_toolandinvoke_agent, or{operation} {model}with a model, dropping the tool or agent name in the span name.gen_ai.tool.nameandgen_ai.agent.namecome from the span name, which becomesexecute_tool {name}orinvoke_agent {name}, even with a model, per gen-ai-spans.md:1148 and gen-ai-agent-spans.md:555. An autologger that names spans{Class}.{method}exports that string, so a pydantic-ai 2.xagent.run()exportsinvoke_agent Agent.run.execute_tool {name}andinvoke_agent {name}. The translator overwrote those names with the bare operation, or withinvoke_agent {model}for a Strands agent with amodel_id.How is this PR tested?
Does this PR require documentation update?
Does this PR require updating the MLflow Skills repository?
Release Notes
Is this a user-facing change?
GenAI semconv export now names tool and agent spans
execute_tool {name}andinvoke_agent {name}from the original span name, and setsgen_ai.tool.nameandgen_ai.agent.name. Previously the names were the bare operation or{operation} {model}.What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityHow should the PR be classified in the release notes? Choose one:
rn/bug-fix- A user-facing bug fixIs this PR a critical bugfix or security fix that should go into the next patch release?
@aaronteo-db @B-Step62 is
invoke_agent Agent.runfine, or should autologgers setgen_ai.agent.name?