Skip to content

Conversation

yiyuan-he
Copy link

@yiyuan-he yiyuan-he commented Oct 6, 2025

Fixes #2837

Changes

Expands the invoke_agent span semantic conventions to cover all agent invocation scenarios, not just remote agents.

Added guidance for span kind:

  • CLIENT: For remote agent services (OpenAI Assistants API, AWS Bedrock)
  • INTERNAL: For in-process agents (LangChain, CrewAI agents)
  • SERVER: For instrumenting the agent service itself

Also added explicit guidance that server.address and server.port attributes should only be set when the span kind is CLIENT.

Note: if the PR is touching an area that is not listed in the existing areas, or the area does not have sufficient domain experts coverage, the PR might be tagged as experts needed and move slowly until experts are identified.

Merge requirement checklist

  • CONTRIBUTING.md guidelines followed.
  • Change log entry added, according to the guidelines in When to add a changelog entry.
    • If your PR does not need a change log, start the PR title with [chore]
  • Links to the prototypes or existing instrumentations (when adding or changing conventions)
    • N/A - Documentation clarification only, no new conventions added

component: gen-ai

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "`invoke_agent` spans now include span kind guidance (CLIENT/INTERNAL/SERVER) and clarify when `server.*` attributes should be set."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about following?

s/span kind guidance (CLIENT/INTERNAL/SERVER)/span kind (CLIENT/INTERNAL/SERVER) guidance

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! Updated to be "span kind (CLIENT/INTERNAL/SERVER) guidance"

invocation of agents running in the same process or `SERVER` when instrumenting
the agent service itself.
It's RECOMMENDED to use `CLIENT` kind when the agent being instrumented usually runs
in a different process than its caller or when the agent invocation happens over
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add more clarification when to use different span kind, like what you clarified

CLIENT: For remote agent services (OpenAI Assistants API, AWS Bedrock)
INTERNAL: For in-process agents (LangChain, CrewAI agents)
SERVER: For instrumenting the agent service itself

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated documentation note section with examples

Comment on lines 189 to 190
invocation of agents running in the same process or `SERVER` when instrumenting
the agent service itself.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Server kind seems to be a step too far and there is a clear pattern of splitting the definition given that the attributes change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point - I've removed the SERVER span kind references from this PR for now. Seems like this case will need further discussion and can be addressed in a follow-up.

in a different process than its caller or when the agent invocation happens over
instrumented protocol such as HTTP.

`server.address` and `server.port` attributes SHOULD be set when span kind is `CLIENT`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be defined via the yaml model ie note on the requirement level.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - moved to the yaml model as conditionally required attributes.

conditionally_required: if applicable.
- ref: server.address
requirement_level:
conditionally_required: when span kind is `CLIENT`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's recommended now, is there a reason to change it?

Suggested change
conditionally_required: when span kind is `CLIENT`.
recommended: when span kind is `CLIENT`.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention was to make it required only when the span kind is CLIENT. I can change it back to recommended though if this is confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other conventions don't (conditionally) require server.address on logical operations (check out DB or messaging). LLM calls are inherently logical - underlying HTTP / gRPC / protocol spans would represent physical call and contain details. So I don't see a strong reason to change existing requirement level for LLMs and would suggest reverting it back to recommended.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for the clarification. Reverted it back to recommended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

GenAI agent spans: invoke_agent could be internal / server ?

5 participants