Skip to content

feat(llmobs): add first-class memory span kind and agent memory instrumentation - #22119

Draft
FouadWahabi wants to merge 4 commits into
mainfrom
fouad.wahabi/agent-memory-observability
Draft

FouadWahabi wants to merge 4 commits into
mainfrom
fouad.wahabi/agent-memory-observability

Conversation

@FouadWahabi

@FouadWahabi FouadWahabi commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Adds first-class agent memory observability to ddtrace.llmobs using a dedicated memory span kind (with workflow for standalone roots) and raw text confined to span I/O for SDS scrubbing.

  • Manual API: LLMObs.memory(), @memory decorator (sync/async/generators), and LLMObs.annotate(memory=...) with MemoryRecord/MemoryAnnotation TypedDicts
  • Dedicated memory span kind supporting both output.documents on reads and output.value on mutations
  • Bounded meta.metadata.memory schema with SHA-256 hashed principals/tenants/content hashes and flat underscore memory_* metrics
  • Auto-instrumentation for LangGraph BaseStore (put/get/search/delete + async variants) and native memory_* tool calls
  • Unit, layering, and real-library tests (tests/llmobs/test_memory.py, langgraph 1.2.24, SDK v2.14)

…mentation

Add zero-drop agent memory tracing via LLMObs.memory(), @memory, and LLMObs.annotate(memory=...)
with bounded metadata, SHA-256 identifier/content hashing, and flat underscore metrics, plus
auto-instrumentation for LangGraph BaseStore and native memory_* tool calls.
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

ddtrace/contrib/internal/langgraph/patch.py                             @DataDog/ml-observability
ddtrace/llmobs/__init__.py                                              @DataDog/ml-observability
ddtrace/llmobs/_integrations/anthropic.py                               @DataDog/ml-observability
ddtrace/llmobs/_integrations/langgraph.py                               @DataDog/ml-observability
ddtrace/llmobs/_llmobs.py                                               @DataDog/ml-observability
ddtrace/llmobs/_memory.py                                               @DataDog/ml-observability
ddtrace/llmobs/decorators.py                                            @DataDog/ml-observability
ddtrace/llmobs/types.py                                                 @DataDog/ml-observability
releasenotes/notes/llmobs-agent-memory-observability-7a9b4c2d1e0f8a3b.yaml  @DataDog/apm-python
tests/llmobs/test_memory.py                                             @DataDog/ml-observability

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 22 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 22 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=103)
ddtrace.llmobs._integrations.bedrock_agents -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=101)
ddtrace.llmobs._integrations.base -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=101)
ddtrace.internal.span_bus -×-> ddtrace._trace.span  (internal-core -> product:tracing, score=35)
ddtrace.llmobs._llmobs -×-> ddtrace._trace.span  (product:llmobs -> product:tracing, score=33)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

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

@pr-commenter

pr-commenter Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-26 13:34:25

Comparing candidate commit 4f20838 in PR branch fouad.wahabi/agent-memory-observability with baseline commit b9d1844 in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 21 metrics, 0 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 ----------------------------------'

…ions

Emit span_kind="memory" for child memory spans instead of overloading retrieval, tool, or task
(keeping "workflow" for standalone root spans), and support both output.documents on reads
and output.value on mutations.
@FouadWahabi FouadWahabi changed the title feat(llmobs): add agent memory observability API and instrumentation feat(llmobs): add first-class memory span kind and agent memory instrumentation Nov 26, 2026
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.

1 participant