Skip to content

feat(llmobs): add annotateAgentManifest manual API to LLMObs SDK - #12318

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 7 commits into
masterfrom
yahya/llmobs-agent-manifest-manual
Aug 31, 2026
Merged

feat(llmobs): add annotateAgentManifest manual API to LLMObs SDK#12318
gh-worker-dd-mergequeue-cf854d[bot] merged 7 commits into
masterfrom
yahya/llmobs-agent-manifest-manual

Conversation

@yahya-mouman

Copy link
Copy Markdown
Contributor

Summary

Adds annotateAgentManifest(LLMObs.AgentManifest) to the Java LLMObs SDK, allowing users to manually declare an agent span's configuration (name, instructions, model, model_settings, tools). Mirrors the Python implementation (DataDog/dd-trace-py#19771) and follows the annotatePrompt pattern from #12161.

Changes

  • LLMObsTags.java — adds AGENT_MANIFEST = "agent_manifest" constant
  • LLMObs.java — adds two public immutable builder classes:
    • LLMObs.AgentTool — represents a single tool (name, optional description, optional parameters)
    • LLMObs.AgentManifest — builder with name, instructions, model, model_settings, tools
  • LLMObsSpan.java — adds default void annotateAgentManifest(LLMObs.AgentManifest) (no-op default for backwards compat)
  • NoOpLLMObsSpan.java — explicit @Override no-op
  • DDLLMObsSpan.java — real implementation: validates span kind (agent only), builds manifest map, stores as _ml_obs_tag.agent_manifest
  • LLMObsSpanMapper.java — adds agent_manifest to TAGS_FOR_REMAPPING; serializes to meta.agent_manifest as a msgpack map

Behaviour

LLMObs.AgentManifest manifest = LLMObs.AgentManifest.builder()
    .name("travel_desk")
    .instructions("Book travel for the user.")
    .model("gpt-4o")
    .modelSettings(Map.of("temperature", 0.7))
    .tools(List.of(LLMObs.AgentTool.from("get_weather", "Look up weather", null)))
    .build();

agentSpan.annotateAgentManifest(manifest);
  • Only applies to agent span kind; other span kinds emit a log warning and no-op
  • Calling twice on the same span overwrites the previous manifest (no merge)
  • framework is set to "AgentObs SDK" automatically by the SDK
  • name defaults to the span name if not provided
  • model_settings keys are forwarded as-is (no allowlist in this initial PR)
  • Null manifest is silently ignored

Test plan

  • ./gradlew :dd-trace-api:test --tests "datadog.trace.api.llmobs.LLMObsTest" — 27 tests pass (4 new)
  • ./gradlew :dd-java-agent:agent-llmobs:test --tests "datadog.trace.llmobs.domain.DDLLMObsSpanTest" — 39 tests pass (7 new)
  • ./gradlew :dd-trace-core:test --tests "datadog.trace.llmobs.writer.ddintake.LLMObsSpanMapperTest" — 18 tests pass (2 new)

🤖 Generated with Claude Code

yahya-mouman and others added 4 commits August 27, 2026 13:36
- Add AgentManifest immutable value class with Builder pattern in LLMObs.java
- Add AgentTool immutable value class in LLMObs.java
- Add AGENT_MANIFEST constant to LLMObsTags
- Add annotateAgentManifest() default method to LLMObsSpan interface
- Add comprehensive builder tests for AgentManifest and AgentTool

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Stores agent manifest fields (name, instructions, model, model_settings,
tools) as an internal tag `_ml_obs_tag.agent_manifest`. Only applies to
agent spans; warns and no-ops on other span kinds. Null manifest is
silently ignored. Tools with null/empty names are skipped with a warning.
A second call overwrites the previous manifest. Framework field
"AgentObs SDK" is always added when any manifest fields are present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add AGENT_MANIFEST_KEY byte constant, include the tag in TAGS_FOR_REMAPPING,
and handle it in the meta serialization loop as a msgpack map. Add two
tests: one verifying all manifest fields appear in meta, one verifying
the tag does not leak into the tags list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yahya-mouman yahya-mouman added the type: feature Enhancements and improvements label Aug 27, 2026
@datadog-prod-us1-6

This comment has been minimized.

@ncybul

ncybul commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@codex

@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: b5f56f11d6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@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.

A couple minor suggestions but overall looks good to me! Would be nice to see a manual verification of setting the manifest via the SDK.

Comment thread dd-trace-api/src/main/java/datadog/trace/api/llmobs/LLMObs.java Outdated
@yahya-mouman
yahya-mouman marked this pull request as ready for review August 28, 2026 11:08
@yahya-mouman
yahya-mouman requested a review from a team as a code owner August 28, 2026 11:08
@dd-octo-sts dd-octo-sts Bot added the tag: ai generated Largely based on code generated by an AI or LLM label Aug 28, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

@datadog-prod-us1-6 datadog-prod-us1-6 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.

Datadog Autotest: PASS

More details

The default API method keeps compatibility. The implementation accepts manifests only for agent spans and writes them to meta.agent_manifest.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit b5f56f1 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

…test hardening

- Change annotateAgentManifest to merge successive calls instead of
  overwriting: name/instructions/model use new-value-wins logic with
  fallbacks; model_settings shallow-merges; tools replace only when
  caller provides a non-empty list.
- Change MANUAL_FRAMEWORK constant from "AgentObs SDK" to "manual".
- Update all test assertions that expected "AgentObs SDK" to "manual".
- Replace overwrite test with merge-semantics test; add model_settings
  merge test.
- Tests for post-finish no-op and empty-tools-list were already present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@sabrenner sabrenner 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.

one main comment a couple nits otherwise lgtm!

Comment thread dd-trace-api/src/main/java/datadog/trace/api/llmobs/LLMObs.java
yahya-mouman and others added 2 commits August 28, 2026 19:43
…domain/DDLLMObsSpan.java

Co-authored-by: Sam Brenner <106700075+sabrenner@users.noreply.github.com>
…nce; update docstring

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yahya-mouman yahya-mouman added the comp: mlobs ML Observability (LLMObs) label Aug 31, 2026
@yahya-mouman
yahya-mouman added this pull request to the merge queue Aug 31, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 31, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-31 10:59:50 UTC ℹ️ Start processing command /merge


2026-08-31 10:59:55 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-08-31 11:47:18 UTCMergeQueue: The build pipeline contains failing jobs for this merge request

Build pipeline has failing jobs for 5fa0942:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.
Details

Since those jobs are not marked as being allowed to fail, the pipeline will most likely fail.
Therefore, and to allow other builds to be processed, this merge request has been rejected and the pipeline got canceled.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 31, 2026
@yahya-mouman

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 31, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-31 13:21:47 UTC ℹ️ Start processing command /merge


2026-08-31 13:21:51 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-08-31 14:25:17 UTC ℹ️ MergeQueue: This merge request was merged

@yahya-mouman
yahya-mouman added this pull request to the merge queue Aug 31, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 31, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-31 14:01:18 UTC ℹ️ Start processing command /merge


2026-08-31 14:01:21 UTC ❌ MergeQueue

PR already in the queue with status in_progress

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 31, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit e149937 into master Aug 31, 2026
604 of 605 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the yahya/llmobs-agent-manifest-manual branch August 31, 2026 14:25
@github-actions github-actions Bot added this to the 1.66.0 milestone Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: mlobs ML Observability (LLMObs) tag: ai generated Largely based on code generated by an AI or LLM type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants