Fix instrumented embedding spans missing the `embeddings` attribute when `include_content=True`
This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.
Closes #8293
Why we make these changes
With include_content=True, the default, InstrumentedEmbeddingModel.embed wrote the returned vectors into the attributes dict that span creation had already consumed. As a result, the exported span never carried the embeddings attribute that its own logfire.json_schema declares. The fix writes the vectors through attributes_to_set, which reaches the live span via span.set_attributes(), the same path every other response attribute takes.
This PR includes the two-sided regression test from #8364 by @anupamking01, who is credited as co-author on that commit.
New public surface
None.
User-visible behavior
embedder = Embedder(TestEmbeddingModel(dimensions=3), instrument=True)
await embedder.embed_query('hello')
# exported span attributes['embeddings']
# before: missing
# after: '[[1.0, 1.0, 1.0]]'
Verification
test_instrumentation_embeddings_honor_include_content: the span carries the vectors withinclude_content=Trueand omits them withFalse.TestOpenAI,TestBedrockandTestGoogle::test_instrumentation: each snapshot gainsembeddings, matched by shape (IsList(IsList(IsFloat(), length=N), length=1)). The cassettes are unchanged.
What changes for existing users
Embedding spans recorded with include_content on now carry the embeddings attribute; spans recorded with include_content=False and error spans are unchanged.
PR decisions
2026-11-03 · adopted PR #8295 at 2026-11-03 · iter -
- Decision: Branch-context bootstrapped from existing PR + issue. No resolved threads to backfill.
- Why: PR predates the branch-context setup
- Source: https://github.com/pydantic/pydantic-ai/pull/8295
2026-11-03 · carry the fix on #8295 · iter -
- Decision: David chose adopting #8295 over a fresh PR and over taking over #8364.
- Why: #8295 already carries the fix and snapshot refresh; #8364 adds only a False-side test
- Source: https://github.com/pydantic/pydantic-ai/issues/8293#issuecomment-6504587007
2026-11-03 · adoption plan · iter -
- Decision: pydanty:cancel label; merge main; snapshot vectors as IsList(IsList(IsFloat(), length=N), length=M); fold #8364 include_content=False test with Co-authored-by; body closes #8293 and credits #8364; reply on #8293, close #8364.
- Why: manager dispatch for David
- Source: https://github.com/pydantic/pydantic-ai/pull/8364
2026-11-03 · fold #8364 test as one parametrized capfire test · iter -
- Decision: Replace pydanty's raw-OTel True-side test with test_instrumentation_embeddings_honor_include_content, parametrized over include_content, carrying #8364's two assertions; drop the opentelemetry-sdk try_import it needed.
- Why: Mirrors adjacent test_instrumentation_exception_honors_include_content; capfire is the file's idiom and needs no extra import guard. False case overlaps test_limited_instrumentation's full-attribute snapshot.
- Source: https://github.com/pydantic/pydantic-ai/pull/8364/files
- Session: ad3e0f6d-83ae-4433-8b87-e96ec5e08bbb
2026-11-04 · pre-push review 1 of 3 at 954ad0f64 · iter -
- Decision: reserved; outcome pending
- Why: reviewed tree be99ec4e1cf1882a79989374a1f6522cd4c2cc8f; scope full branch 03988a640...954ad0f64; first review
- Source: https://github.com/pydantic/pydantic-ai/pull/8295
- Session: ad3e0f6d-83ae-4433-8b87-e96ec5e08bbb
2026-11-04 · pre-push review 1 of 3 at 954ad0f64 · iter -
- Decision: remediated: only finding was the stale test name in the pydanty PR body; body rewrite names test_instrumentation_embeddings_honor_include_content. No code findings.
- Why: reviewed tree be99ec4e1cf1882a79989374a1f6522cd4c2cc8f; scope full branch 03988a640...954ad0f64; first review
- Source: https://github.com/pydantic/pydantic-ai/pull/8295
- Session: ad3e0f6d-83ae-4433-8b87-e96ec5e08bbb
2026-11-04 · no second opinion; enqueued at 954ad0f64 · iter -
- Decision: David chose no additional review surface; the manager enqueued #8295 at position 1 on 954ad0f64.
- Why: merge bar met: CI green, clean douwebot APPROVE on 954ad0f64, metadata current
- Source: https://github.com/pydantic/pydantic-ai/pull/8295#pullrequestreview-5761491656
- Session: ad3e0f6d-83ae-4433-8b87-e96ec5e08bbb
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it. (N/A: no compatibility impact.)
- PR title is fit for the release changelog.