Skip to content

Count and trace tool calls made by native agent frameworks - #73901

Merged
kaxil merged 1 commit into
commonai-hook-pinned-argumentsfrom
commonai-native-observability
Sep 30, 2026
Merged

kaxil merged 1 commit into
commonai-hook-pinned-argumentsfrom
commonai-native-observability

Conversation

@kaxil

@kaxil kaxil commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

A Strands or ADK agent running in a plain Python task was invisible in Airflow's metrics and its traces: nothing counted its tool calls, its spans carried prompts and tool results by default, and they were not tied to the task.

  • common_ai.tool_calls is incremented for every call to a connection-backed toolset this provider ships, tagged with the toolset class, the framework making the call (pydantic_ai, strands, adk, langchain or none) and the outcome (executed, failed or replayed). Tags stay low-cardinality: never arguments, connection IDs, table names or paths.
  • agent_framework_tracing() wraps the code that builds and runs the agent. Inside the block, three things hold:
    • The framework leaves prompts, completions and tool inputs and outputs out of its spans unless [common.ai] otel_export_enabled and capture_content are both on, the same default as AgentOperator.
    • Every span carries the task's Dag ID, run ID, task ID, map index and try number.
    • When no tracer provider made a span for the task, the Dag run's unsampled trace context is not made the framework spans' parent.

The frameworks read their content switches only from the environment, so the helper sets them for the duration of the block. Blocks can overlap when a task runs agents in threads, so the switches stay set until the last one closes. A task runs in its own process, so nothing outside the task sees them.

The helper detaches the parent only when the current span is the Dag run's propagated context itself. That happens only when no tracer provider made a task span. When core tracing or auto-instrumentation made one, the Dag run was sampled out on purpose, and the helper leaves that decision alone. This is the same rule as #73903, which changes the task span itself; the helper covers Airflow versions without that fix. The metric and the helper are experimental and listed on the stability page.

ADK and Strands spans nested under their task spans, and a Strands tool span carrying the task's identity:

Trace of the end-to-end run

Strands tool span with airflow.* attributes


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@kaxil
kaxil force-pushed the commonai-native-observability branch from 79eac1c to c838fac Compare September 29, 2026 20:07
Every call to a toolset this provider ships increments
common_ai.tool_calls, tagged with the toolset class, the agent framework
making the call (pydantic_ai, strands, adk, langchain or none) and the
outcome (executed, failed or replayed).

agent_framework_tracing() wraps the code that builds and runs a Strands
or Google ADK agent. Inside it the framework leaves prompts, completions
and tool inputs and outputs out of its spans unless
[common.ai] capture_content is on, spans carry the task's identity like
AgentOperator's, and with worker tracing off the Dag run's unsampled
trace context no longer drops the framework's spans.
@kaxil
kaxil force-pushed the commonai-native-observability branch from c838fac to b053ff0 Compare September 30, 2026 06:01
@kaxil
kaxil merged commit 40ed903 into main Sep 30, 2026
63 of 75 checks passed
@kaxil
kaxil deleted the commonai-native-observability branch September 30, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants