Skip to content

Conversation

@danilop
Copy link

@danilop danilop commented Dec 16, 2025

Description

This PR adds support for web-based and search result citations in the Bedrock Converse API, completing support for all citation location types.

New Features:

  • WebLocation type for web-based citations (url, domain)
  • SearchResultLocation type for search result citations (searchResultIndex, start, end)
  • Updated _format_citation_location to handle all 5 location types

Dependencies

This PR depends on #1343 (fix: Preserve tagged union structure for CitationLocation) which must be merged first.

Related Issues

Fixes #1345

Type of Change

New feature

Testing

  • I ran hatch run prepare (1618 tests pass)
  • Tests for web citations
  • Tests for search result citations
  • Tests for field filtering

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 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.

Danilo Poccia added 2 commits December 16, 2025 09:27
The Bedrock API requires CitationLocation to be a tagged union with
exactly one wrapper key (documentChar, documentPage, or documentChunk).

Changes:
- Refactor citation type definitions to use Inner types + wrapper types
  for proper tagged union modeling
- Add _format_citation_location helper method to preserve union structure
- Add tests for all document-based citation location types

BREAKING CHANGE: CitationLocation types now use wrapper structure
(e.g., {'documentChar': {'documentIndex': 0, ...}}) instead of flat
structure. This matches the actual Bedrock API specification.

Fixes strands-agents#1323
Add support for web-based and search result citations in the Bedrock
Converse API, enabling the SDK to handle all citation location types.

Changes:
- Add WebLocation and WebLocationInner types for web citations
- Add SearchResultLocation and SearchResultLocationInner types
- Update _format_citation_location to handle web and searchResultLocation
- Add tests for web and search result citation types

This completes support for all CitationLocation types as per the
Bedrock Converse API specification.
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.

[FEATURE] Add support for web and search result citations in Bedrock

1 participant