Skip to content

tool call tracing #40518

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

Open
wants to merge 14 commits into
base: feature/azure-ai-projects-beta9
Choose a base branch
from

Conversation

M-Hietala
Copy link
Contributor

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

dargilco and others added 13 commits March 7, 2025 15:18
#40023)

* fixing a bug with agent tracing causing event hander return values to no be returned

* code checker tool related changes

---------

Co-authored-by: Marko Hietala <[email protected]>
* Show the reference in sample

* Fix

* Fixes

* Fix
* Regeerate python code to use extensible connection types

* Regenerate from upstream
* fixing tool call tracing

* review related changes and code checker tool related changes

---------

Co-authored-by: Marko Hietala <[email protected]>
Co-authored-by: Darren Cohen <[email protected]>
@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-ai-projects

@@ -42,6 +42,13 @@
GEN_AI_USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens"
GEN_AI_SYSTEM_MESSAGE = "gen_ai.system.message"
GEN_AI_EVENT_CONTENT = "gen_ai.event.content"
GEN_AI_CREATED_AT = "gen_ai.created_at"
Copy link
Member

@lmolkova lmolkova Apr 15, 2025

Choose a reason for hiding this comment

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

this attribute is not defined in the conventions. If you think it's important to record, we'll need to find a descriptive name - is it a message creation time?

Copy link
Contributor Author

@M-Hietala M-Hietala Apr 16, 2025

Choose a reason for hiding this comment

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

it is the tool call and message creation creation time, and then there is corresponding complted/cancelled/failed at

@@ -42,6 +42,13 @@
GEN_AI_USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens"
GEN_AI_SYSTEM_MESSAGE = "gen_ai.system.message"
GEN_AI_EVENT_CONTENT = "gen_ai.event.content"
GEN_AI_CREATED_AT = "gen_ai.created_at"
GEN_AI_COMPLETED_AT = "gen_ai.completed_at"
Copy link
Member

Choose a reason for hiding this comment

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

is it about run ?

if you think we should capture it, let's call it gen_ai.run | run_step.end.timestamp

Copy link
Contributor Author

@M-Hietala M-Hietala Apr 16, 2025

Choose a reason for hiding this comment

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

these are reported for the tool calls and message creation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed these to
gen_ai.run_step.start.timestamp
gen_ai.run_step.end.timestamp
gen_ai.run_step.cancel.timestamp
gen_ai.run_step.fail.timestamp

completed_at=step.completed_at,
cancelled_at=step.cancelled_at,
failed_at=step.failed_at,
run_step_last_error=step.last_error,
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

the code should go to error.type and the message should go to error.string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}
else:
try:
step_details = str(step["step_details"]["tool_calls"])
Copy link
Member

Choose a reason for hiding this comment

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

should we do json dumps instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that causes an error

tool_call = {
"id": t.id,
"type": t.type,
"tool_call_details": step_details,
Copy link
Member

@lmolkova lmolkova Apr 15, 2025

Choose a reason for hiding this comment

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

Suggested change
"tool_call_details": step_details,
t.type: step_details,

I believe the patterns is

"type" : {tool name}
{tool name}: {details}

https://platform.openai.com/docs/api-reference/run-steps/step-object#run-steps/step-object-step_details

so while we don't know the structure for arbitrary tool, we know the name, let's use it instead of generic ``tool_call_details`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

GEN_AI_FAILED_AT,
GEN_AI_RUN_STEP_STATUS,
GEN_AI_RUN_STEP_LAST_ERROR,
GEN_AI_RUN_STEP_DETAILS,
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 not used, can you please remove it along with the definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


if created_at:
created_at_string = created_at.strftime("%Y-%m-%d %H:%M:%S.%f")
attrs[GEN_AI_CREATED_AT] = created_at_string
Copy link
Member

Choose a reason for hiding this comment

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

the conventional way to record timestamps in otel is ISO 8601, if we end up recording this attribute, let's use it

(and similar for other attributes)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Base automatically changed from feature/azure-ai-projects-beta9 to main April 16, 2025 18:59
@dargilco dargilco changed the base branch from main to feature/azure-ai-projects-beta9 April 16, 2025 19:13
@M-Hietala M-Hietala mentioned this pull request Apr 18, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants