Repository navigation
Add gen_ai.agent.steps metric #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7fe63e4
f0a82a3
f4f0a4c
26131bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,6 +116,49 @@ metrics: | |
| - ref: gen_ai.workflow.name | ||
| requirement_level: | ||
| conditionally_required: If available. | ||
| - name: gen_ai.agent.steps | ||
| annotations: | ||
| code_generation: | ||
| metric_value_type: int | ||
| brief: > | ||
| Number of steps a GenAI agent takes during a single invocation. | ||
| note: | | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we only count completed steps, or also include partial / failed steps too?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New answer: tbc |
||
| Recorded once per agent invocation. A "step" is a framework-defined | ||
| unit of work that the agent itself performs during the invocation; | ||
| instrumentations MUST count only steps the agent itself authored. | ||
|
|
||
| Common framework-specific definitions: | ||
|
|
||
| - **ADK**: each [event](https://adk.dev/runtime/event-loop/#event) in | ||
| the invocation context whose `event.author` equals the agent name | ||
| (typically a model response, a tool call the agent issued, or an | ||
| agent transfer the agent initiated). Tool results, which are | ||
| authored by the tool rather than the agent, are not counted. | ||
| - **LangGraph**: each node execution the agent itself performed in | ||
| the workflow graph. | ||
| - **LangChain agents**: each `AgentAction` or `AgentFinish` step the | ||
| agent itself emitted. | ||
| - **CrewAI**: each agent turn the agent itself took within a task. | ||
|
|
||
| Steps emitted by sub-agents or by the surrounding workflow SHOULD | ||
| NOT be counted; each step SHOULD be recorded exactly once across | ||
| the full call tree. | ||
|
|
||
| Steps are counted regardless of outcome: a step that errored or | ||
| partially completed still consumed the agent's execution and SHOULD | ||
| be counted. | ||
|
|
||
| Step counts MUST NOT be compared across different frameworks. They | ||
| are only meaningful within the context of a single framework's | ||
| instrumentation, which is why instrumentations MUST document what | ||
| counts as a step for their framework. | ||
| instrument: histogram | ||
|
pvlsirotkin marked this conversation as resolved.
|
||
| unit: "{step}" | ||
| stability: development | ||
| attributes: | ||
|
pvlsirotkin marked this conversation as resolved.
|
||
| - ref_group: attributes.gen_ai.error | ||
| - ref: gen_ai.agent.name | ||
| requirement_level: recommended | ||
|
|
||
| metric_refinements: | ||
| - id: openai.client.token.usage | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a bit of a research and I think this generalization would be confusing, it does not make sense to merge these things into one metric unless they are comparable:
stepused in the metric name would be misleading. Langgraph also has configurablerecursion_limitfor number of super-steps andremaining_stepsin the step that provides number of remaining ones until limit is reached. This is a signal that these things could be meaningful to LangGraph users.iterationsin agent executor - https://github.com/crewAIInc/crewAI/blob/b6e5d632c111e098d883274f0a26f02836a2172e/lib/crewai/src/crewai/agents/crew_agent_executor.py#L218 and there is a corresponding config for max_interations, but iteration is a full ReAct loop. It has something calledstep_callbackbut does not clearly document when it's called.I think this metric tries to capture something that's a proxy to number of loops / iterations within one agent, but tries to express it through internal frameowrk implementation details.
Some alternative approaches:
gen_ai.inference | execute_tool.durationand invoke agent duration. This won't give outliers or percentiles, but arguably many loops / events also leads to long invoke_agent duration.gen_ai.agent.inference_calls_per_invocation,gen_ai.agent.tool_calls_per_invocations,gen_ai.agent.transfers_per_invocation- these are understandable and generically applicable. The list can probably grow with retrievals and memory calls[gcp.]adk.event_loop.event.countwith attributes for author and type or[gcp].adk.event_loop.events_per_invocationwould be specific and understandable. Langgraph and crewai would have specialized metrics tooApproaches 1 and 2 can exist together:
gen_ai.agent.inference_calls_per_invocationcould be a common 'give me a sense of how long this agent invocation was' that shows up on common dashboards and[gcp].adk.event_loop.events_per_invocationcan be a detailed breakdown. This would align with t-shaped signals approach.