Skip to content

feat(llmobs): accept an agent manifest manually - #10480

Merged
mz1119 merged 10 commits into
masterfrom
max.zhang/llmobs-agent-manifest
Oct 8, 2026
Merged

mz1119 merged 10 commits into
masterfrom
max.zhang/llmobs-agent-manifest

Conversation

@mz1119

@mz1119 mz1119 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds an agent option to llmobs.annotate() and llmobs.annotationContext(). name, instructions, model, modelSettings and tools are reported as the agent's manifest under meta.metadata._dd.agent_manifest.

llmobs.annotate({
  agent: {
    name: 'travel_desk',
    instructions: 'Book travel.',
    model: 'gpt-4o',
    modelSettings: { temperature: 0.1, maxTokens: 1024 },
    tools: [{ name: 'get_weather', parameters: { city: { type: 'string', required: true } } }],
  },
})

Behavior:

  • Agent spans only. framework is set to manual, and name defaults to the span name.
  • The manifest is resolved when the span finishes, so spans promoted to agents after start (claude-agent-sdk sub-agents) get it.
  • An annotationContext declaration is read once when the context is entered and reaches every agent span in the block, like every other annotation. annotate on a nested agent span overrides it for that span.
  • Each declaration is validated, then shallow-updates the manifest: a later field (modelSettings and tools included) replaces an earlier one whole, and unset or invalid values (undefined, null, '', []) leave it in place.
  • Each field is validated on its own. Unreportable fields are dropped and logged by name, never by value. modelSettings is limited to an allowlist, so keys like extra_headers are never reported. Only plain objects are read, so schema-library objects must be converted to JSON Schema first. Tool parameters accept { param: { type, required } } or a JSON Schema object.
  • Reading the declaration never throws, so a throwing getter on a caller's object cannot break span creation or disable an integration.

Also fixes a pre-existing bug where annotate({ tags }) inside annotationContext({ tags }) wrote into the context's tags object.

Testing

Example traces:
trace with nested manifest

simple trace

Motivation

Parity with dd-trace-py (DataDog/dd-trace-py#19771) and dd-trace-java (DataDog/dd-trace-java#12318), so manually instrumented agents render a manifest.

Additional Notes

🤖 Generated with Claude Code

@dd-octo-sts

dd-octo-sts Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 9.46 MB
Deduped: 10.21 MB
No deduping: 10.21 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.5.1 | 127.66 kB | 531.94 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.87%. Comparing base (5dc0c26) to head (1378ecf).
⚠️ Report is 67 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10480      +/-   ##
==========================================
+ Coverage   98.84%   98.87%   +0.03%     
==========================================
  Files        1043     1059      +16     
  Lines      167818   172270    +4452     
  Branches       74       74              
==========================================
+ Hits       165873   170332    +4459     
+ Misses       1945     1938       -7     
Flag Coverage Δ
ai-guard 63.60% <40.64%> (-0.49%) ⬇️
apm-capabilities 54.69% <40.64%> (-0.17%) ⬇️
apm-integrations 80.78% <40.64%> (-0.47%) ⬇️
appsec 57.83% <40.64%> (-0.11%) ⬇️
debugger 69.64% <40.64%> (-0.28%) ⬇️
instrumentation 55.30% <40.64%> (+0.07%) ⬆️
llmobs 80.82% <100.00%> (+0.34%) ⬆️
master-coverage 98.87% <100.00%> (?)
openfeature 67.12% <40.64%> (+1.06%) ⬆️
platform 68.37% <40.64%> (-0.39%) ⬇️
profiling 65.77% <40.64%> (-0.63%) ⬇️
serverless 65.44% <40.64%> (-0.41%) ⬇️
test-optimization 81.69% <40.64%> (-0.33%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-official

datadog-official Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Tests

✅ All CI checks and tests passed. Datadog automation helped this PR pass.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog retried 2 tests - 2 passed on retry View in Datadog

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 98.28% (+0.05%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1378ecf | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-10-08 15:43:23

Comparing candidate commit 1378ecf in PR branch max.zhang/llmobs-agent-manifest with baseline commit 5dc0c26 in branch master.

📊 Benchmarking dashboard

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

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-15.594MB; +10.248MB] or [-6.830%; +4.489%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-26.759MB; +24.389MB] or [-7.567%; +6.897%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable cpu_user_time [-1818.964ms; +657.359ms] or [-19.468%; +7.036%]
  • unstable execution_time [-1853.990ms; +669.205ms] or [-17.665%; +6.376%]
  • unstable throughput [-69.868op/s; +196.880op/s] or [-6.398%; +18.028%]

scenario:encoders-0.4-immediate-flush-20

  • unstable max_rss_usage [-2.241MB; +6.644MB] or [-2.640%; +7.826%]

scenario:plugin-graphql-long-with-depth-and-collapse-off-24

  • unstable cpu_user_time [-789.021ms; +619.531ms] or [-6.922%; +5.435%]
  • unstable execution_time [-790.951ms; +615.477ms] or [-6.842%; +5.324%]
  • unstable throughput [-2.162op/s; +2.679op/s] or [-5.524%; +6.842%]

@mz1119

mz1119 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T15:33:17.250805Z 1378ecf New commits
🔒 Security Review ✅ Completed 2026-10-08T15:31:49.660243Z 1378ecf New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 0e13f295b6

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e13f295b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/dd-trace/src/llmobs/sdk.js
Comment thread packages/dd-trace/src/llmobs/tagger.js Outdated
Comment thread index.d.ts Outdated
Comment thread packages/dd-trace/src/llmobs/agent-manifest.js
@mz1119
mz1119 marked this pull request as ready for review September 28, 2026 18:26
@mz1119
mz1119 requested review from a team as code owners September 28, 2026 18:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b82e8a490

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/dd-trace/src/llmobs/sdk.js
Comment thread packages/dd-trace/src/llmobs/agent-manifest.js

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: caaf6c0cfe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/dd-trace/src/llmobs/agent-manifest.js Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 744541f996

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/dd-trace/src/llmobs/agent-manifest.js Outdated
Comment thread packages/dd-trace/src/llmobs/agent-manifest.js

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ccaba8c139

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/dd-trace/src/llmobs/agent-manifest.js
Comment thread packages/dd-trace/src/llmobs/agent-manifest.js
mz1119 and others added 6 commits September 29, 2026 14:50
Adds an `agent` option to `llmobs.annotate()` and `llmobs.annotationContext()`
that reports `version` as an `agent_version` tag and `name`, `instructions`,
`model`, `modelSettings` and `tools` as the agent's manifest on agent spans.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Keep context declarations outside the caller-controlled annotationContext
  options, so a caller key named `agents` can no longer crash span
  registration or bypass validation.
- Snapshot each declaration once when the context is entered, never
  throwing on unreadable caller objects.
- Give each context manifest to the first agent span of an LLMObs trace, so
  a sibling handoff target keeps its own agent.
- Resolve `agent_version` at finish so spans promoted to agents after
  registration get it, and let it win over a user tag, matching dd-trace-py.
- Treat '' settings as unset, accept only plain objects, drop the
  `model_settings` alias, and log dropped fields by name.
- Copy context tags on first use so annotations cannot write into them.
- Tighten the public Agent types.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copying context tags at span registration read caller getters and Proxy
traps, so an unreadable tags object threw out of span creation (and
disabled integrations) where it was previously contained at finish.
Drop and warn instead. Widen the public `Agent.version` type to accept the
numbers the runtime already reports as strings.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Match dd-trace-py (DataDog/dd-trace-py#19771, 915ac6b46): each validated
declaration shallow-updates the manifest, so a later `model_settings`
replaces an earlier one whole, and an annotation context declares every
agent span in its block instead of the first per trace. Context
declarations are now recorded on every span in the block and emitted if
the span is an agent at finish, so spans promoted to agents after
registration get the manifest too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A schema with `properties` but neither `type` nor `required` is read as a
parameter map at runtime (matching dd-trace-py), so its parameters were
silently dropped while the public type accepted it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The public type accepts numeric versions and reports them as strings, but a
truthiness check dropped `0`. Only `undefined`, `null`, `''` and non-finite
numbers now declare no version.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mz1119 and others added 2 commits September 29, 2026 14:50
Keeps this change to the agent manifest. The `agent_version` tag lands separately.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Tool parameters and `logit_bias` are built with `Object.fromEntries`, so a key named `__proto__` from a
JSON-parsed schema becomes an own property instead of setting the prototype and being dropped.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mz1119
mz1119 force-pushed the max.zhang/llmobs-agent-manifest branch from 7c81b89 to 813fe04 Compare September 29, 2026 18:51
@khanayan123

Copy link
Copy Markdown
Collaborator

Hi @mz1119 is this PR ready for human review? if not please consider converting the PR back to draft :)

@ncybul ncybul left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I still need to take a look at the tests, but leaving some initial comments here!

Comment thread docs/test.ts
Comment thread packages/dd-trace/src/llmobs/agent-manifest.js Outdated
Comment thread packages/dd-trace/src/llmobs/agent-manifest.js Outdated
Comment thread index.d.v5.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread packages/dd-trace/test/llmobs/agent-manifest.spec.js Outdated
Comment thread packages/dd-trace/test/llmobs/sdk/index.spec.js Outdated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mz1119
mz1119 merged commit 80f6ca5 into master Oct 8, 2026
678 checks passed
@mz1119
mz1119 deleted the max.zhang/llmobs-agent-manifest branch October 8, 2026 17:24
This was referenced Oct 9, 2026
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.

3 participants