Skip to content

Conversation

@danilop
Copy link

@danilop danilop commented Nov 11, 2025

Description

This PR adds support for web-based citations in the Bedrock Converse API, enabling the SDK to handle citations from web sources in addition to document-based citations.

Changes:

  • Added WebLocation TypedDict to src/strands/types/citations.py with url and domain fields
  • Updated CitationLocation union type to include the new WebLocation type
  • Enhanced citation location filtering in src/strands/models/bedrock.py to handle web-based citations
  • Refactored citation metadata processing to use safer dictionary comprehension that only includes fields present in the citation

All citation location types (document-based and web-based) are now supported as per the updated Bedrock Converse API specification.

Related Issues

This was a blocking issue for #1154

Documentation PR

N/A

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

domain: str


class DocumentChunkLocation(TypedDict, total=False):
Copy link
Member

Choose a reason for hiding this comment

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

Hi, we have to preserve backwards compatibility. So we cannot simply remove these classes.

These are typeddicts, so I see the argument that it would not be possible from someone to leverage
CitationLocation = Union[DocumentCharLocation, DocumentChunkLocation, DocumentPageLocation] to do instanceof checks in the first place. But this still needs to be workshopped to avoid breaking changes

@kpx-dev
Copy link

kpx-dev commented Dec 9, 2025

hi team, any update on this? One of my customer is also looking forward for this feature support to test out Nova Web Grounding.

@danilop
Copy link
Author

danilop commented Dec 11, 2025

All types should be back now for backward compatibility.

…rse API

Add support for web-based citations in addition to document-based citations:

- Added WebLocation TypedDict to citations.py with url and domain fields
- Updated CitationLocation union to include WebLocation
- Updated bedrock.py to filter web citation fields (url, domain only)
- Handle optional citation fields gracefully (title, location, sourceContent)
- Added tests for web citations, document citations, and edge cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants