Skip to content

feat(llmobs): [MLOB-2662] [MLOB-3100] add agent manifest #13311

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

Draft
wants to merge 69 commits into
base: main
Choose a base branch
from

Conversation

ncybul
Copy link
Contributor

@ncybul ncybul commented May 1, 2025

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Copy link
Contributor

github-actions bot commented May 1, 2025

CODEOWNERS have been resolved as:

ddtrace/contrib/internal/openai_agents/utils.py                         @DataDog/ml-observability
releasenotes/notes/pydantic-ai-llmobs-tracing-41047b43ecd9167b.yaml     @DataDog/apm-python
releasenotes/notes/remove-openai-agents-redundant-metadata-a397a2317c560e4b.yaml  @DataDog/apm-python
tests/contrib/pydantic_ai/cassettes/agent_run_stream_structured_with_tool.yaml  @DataDog/ml-observability
tests/contrib/pydantic_ai/cassettes/agent_run_stream_with_tools.yaml    @DataDog/ml-observability
tests/contrib/pydantic_ai/test_pydantic_ai_llmobs.py                    @DataDog/ml-observability
tests/contrib/pydantic_ai/utils.py                                      @DataDog/ml-observability
ddtrace/contrib/internal/openai_agents/patch.py                         @DataDog/ml-observability
ddtrace/contrib/internal/pydantic_ai/patch.py                           @DataDog/ml-observability
ddtrace/contrib/internal/pydantic_ai/utils.py                           @DataDog/ml-observability
ddtrace/llmobs/_constants.py                                            @DataDog/ml-observability
ddtrace/llmobs/_integrations/crewai.py                                  @DataDog/ml-observability
ddtrace/llmobs/_integrations/langgraph.py                               @DataDog/ml-observability
ddtrace/llmobs/_integrations/pydantic_ai.py                             @DataDog/ml-observability
ddtrace/llmobs/_integrations/utils.py                                   @DataDog/ml-observability
ddtrace/llmobs/_llmobs.py                                               @DataDog/ml-observability
tests/contrib/openai_agents/test_openai_agents_llmobs.py                @DataDog/ml-observability
tests/contrib/pydantic_ai/conftest.py                                   @DataDog/ml-observability
tests/contrib/pydantic_ai/test_pydantic_ai.py                           @DataDog/ml-observability

Copy link
Contributor

github-actions bot commented May 1, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 281 ± 4 ms.

The average import time from base is: 281 ± 4 ms.

The import time difference between this PR and base is: 0.3 ± 0.2 ms.

The difference is not statistically significant (z = 1.84).

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 1.781 ms (0.63%)
ddtrace.bootstrap.sitecustomize 1.108 ms (0.39%)
ddtrace.bootstrap.preload 1.108 ms (0.39%)
ddtrace.internal.remoteconfig.client 0.601 ms (0.21%)
ddtrace 0.673 ms (0.24%)
ddtrace.internal._unpatched 0.031 ms (0.01%)
json 0.031 ms (0.01%)
json.decoder 0.031 ms (0.01%)
re 0.031 ms (0.01%)
enum 0.031 ms (0.01%)
types 0.031 ms (0.01%)

@pr-commenter
Copy link

pr-commenter bot commented May 1, 2025

Benchmarks

Benchmark execution time: 2025-07-11 20:01:33

Comparing candidate commit c8daba4 in PR branch nicole-cybul/agent-manifest-instrumentation with baseline commit ff294ae in branch main.

Found 0 performance improvements and 3 performance regressions! Performance is the same for 544 metrics, 3 unstable metrics.

scenario:iastaspects-replace_aspect

  • 🟥 execution_time [+689.285ns; +799.209ns] or [+14.581%; +16.907%]

scenario:iastaspects-rstrip_aspect

  • 🟥 execution_time [+735.185ns; +812.064ns] or [+7.151%; +7.898%]

scenario:telemetryaddmetric-1-distribution-metric-1-times

  • 🟥 execution_time [+391.103ns; +424.102ns] or [+13.399%; +14.529%]

@ncybul ncybul changed the title add agent manifest feat(llmobs): [MLOB-2662] add agent manifest May 7, 2025
@github-actions github-actions bot added the stale label Jun 13, 2025
Copy link
Contributor

This pull request has been automatically closed after a period of inactivity.
After this much time, it will likely be easier to open a new pull request with the
same changes than to update this one from the base branch. Please comment or reopen
if you think this pull request was closed in error.

@github-actions github-actions bot closed this Jun 15, 2025
@ncybul ncybul reopened this Jul 9, 2025
Comment on lines 77 to 97
if hasattr(tool, "name"):
tool_dict["name"] = tool.name
if hasattr(tool, "description"):
tool_dict["description"] = tool.description
if hasattr(tool, "strict_json_schema"):
tool_dict["strict_json_schema"] = tool.strict_json_schema
if hasattr(tool, "params_json_schema"):
parameter_schema = tool.params_json_schema
required_params = get_required_param_dict(parameter_schema.get("required", []))
parameters = {}
if "properties" in parameter_schema:
for param, schema in parameter_schema["properties"].items():
param_dict = {}
if "type" in schema:
param_dict["type"] = schema["type"]
if "title" in schema:
param_dict["title"] = schema["title"]
if param in required_params:
param_dict["required"] = True
parameters[param] = param_dict
tool_dict["parameters"] = parameters
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pydantic AI has a very similar schema for tool definitions. It might be helpful to pull the bulk of this logic out into a shared helper function.

Comment on lines +78 to +97
if hasattr(tool, "name"):
tool_dict["name"] = tool.name
if hasattr(tool, "description"):
tool_dict["description"] = tool.description
if hasattr(tool, "strict_json_schema"):
tool_dict["strict_json_schema"] = tool.strict_json_schema
if hasattr(tool, "params_json_schema"):
parameter_schema = tool.params_json_schema
required_params = get_required_param_dict(parameter_schema.get("required", []))
parameters = {}
for param, schema in parameter_schema.get("properties", {}).items():
param_dict = {}
if "type" in schema:
param_dict["type"] = schema["type"]
if "title" in schema:
param_dict["title"] = schema["title"]
if param in required_params:
param_dict["required"] = True
parameters[param] = param_dict
tool_dict["parameters"] = parameters
Copy link
Contributor Author

Choose a reason for hiding this comment

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

PydanticAI has a very similar schema for tool definitions. It may be helpful to pull this out into a shared helper function.

@@ -34,6 +51,8 @@ def patch():
Pin().onto(agents)

add_trace_processor(LLMObsTraceProcessor(OpenAIAgentsIntegration(integration_config=config.openai_agents)))

wrap(agents.Runner, "_run_single_turn", patched_run_single_turn(agents))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this method may have been moved onto the agents.run.AgentRunner class. We may need to condition this patching based on the library version.

@github-actions github-actions bot removed the stale label Jul 10, 2025
@ncybul ncybul changed the title feat(llmobs): [MLOB-2662] add agent manifest feat(llmobs): [MLOB-2662] [MLOB-3100] add agent manifest Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants