Skip to content

fix(ai): address missing attributes and propagate agent name in AI integrations#5727

Open
harryautomazione wants to merge 6 commits intogetsentry:masterfrom
harryautomazione:fix/ai-test-failures
Open

fix(ai): address missing attributes and propagate agent name in AI integrations#5727
harryautomazione wants to merge 6 commits intogetsentry:masterfrom
harryautomazione:fix/ai-test-failures

Conversation

@harryautomazione
Copy link

Description

This PR addresses several AI integration test failures reported in #5343 by fixing missing attributes, propagating the agent name, and structuring response text.

Fixes included:

  1. Langchain: Added gen_ai.tool.type = "function" to on_tool_start in sentry_sdk/integrations/langchain.py to fix missing tool description assertions.
  2. Agent Name Propagation:
    • Introduced a shared context stack in sentry_sdk/ai/utils.py.
    • Updated langgraph.py to manage agent name scope during invoke/ainvoke.
    • Updated openai.py to inherit gen_ai.agent.name from the stack on generated span details.
  3. PydanticAI:
    • Refactored string format wrapper output extraction inside pydantic_ai/spans/invoke_agent.py to construct structured message models when feasible, aligning behavior accurately with multi-turn trace assertions.

Issues

Reminders

@harryautomazione harryautomazione requested a review from a team as a code owner March 20, 2026 17:34
@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (asgi) Add option to disable suppressing chained exceptions by alexander-alderman-webb in #5714
  • (logging) Separate ignore lists for events/breadcrumbs and sentry logs by sl0thentr0py in #5698

Bug Fixes 🐛

Anthropic

  • Set exception info on streaming span when applicable by alexander-alderman-webb in #5683
  • Patch AsyncStream.close() and AsyncMessageStream.close() to finish spans by alexander-alderman-webb in #5675
  • Patch Stream.close() and MessageStream.close() to finish spans by alexander-alderman-webb in #5674

Other

  • (ai) Address missing attributes and propagate agent name in AI integrations by harryautomazione in #5727

Documentation 📚

  • Add note on AI PRs to CONTRIBUTING.md by sentrivana in #5696

Internal Changes 🔧

  • Add -latest alias for each integration test suite by sentrivana in #5706
  • Use date-based branch names for toxgen PRs by sentrivana in #5704
  • 🤖 Update test matrix with new releases (03/19) by github-actions in #5703
  • Add client report tests for span streaming by sentrivana in #5677

Other

  • Update CHANGELOG.md by sentrivana in #5685

🤖 This preview updates automatically when you update the PR.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

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.

❌ AI Integration Tests Failed

1 participant