feat(llmobs): add annotateAgentManifest manual API to LLMObs SDK - #12318
Conversation
- 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>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 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
left a comment
There was a problem hiding this comment.
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.
|
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
There was a problem hiding this comment.
More details
The default API method keeps compatibility. The implementation accepts manifests only for agent spans and writes them to meta.agent_manifest.
🤖 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
left a comment
There was a problem hiding this comment.
one main comment a couple nits otherwise lgtm!
…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>
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
Build pipeline has failing jobs for 5fa0942: What to do next?
DetailsSince those jobs are not marked as being allowed to fail, the pipeline will most likely fail. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
|
/merge |
|
View all feedbacks in Devflow UI.
PR already in the queue with status in_progress |
e149937
into
master
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 theannotatePromptpattern from #12161.Changes
LLMObsTags.java— addsAGENT_MANIFEST = "agent_manifest"constantLLMObs.java— adds two public immutable builder classes:LLMObs.AgentTool— represents a single tool (name, optionaldescription, optionalparameters)LLMObs.AgentManifest— builder withname,instructions,model,model_settings,toolsLLMObsSpan.java— addsdefault void annotateAgentManifest(LLMObs.AgentManifest)(no-op default for backwards compat)NoOpLLMObsSpan.java— explicit@Overrideno-opDDLLMObsSpan.java— real implementation: validates span kind (agent only), builds manifest map, stores as_ml_obs_tag.agent_manifestLLMObsSpanMapper.java— addsagent_manifesttoTAGS_FOR_REMAPPING; serializes tometa.agent_manifestas a msgpack mapBehaviour
agentspan kind; other span kinds emit a log warning and no-opframeworkis set to"AgentObs SDK"automatically by the SDKnamedefaults to the span name if not providedmodel_settingskeys are forwarded as-is (no allowlist in this initial PR)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