Repository navigation
Conversation
lithdew
force-pushed
the
main
branch
2 times, most recently
from
January 22, 2026 21:43
325c94a to
d63bbb1
Compare
lithdew
force-pushed
the
main
branch
2 times, most recently
from
January 23, 2026 15:24
c828c74 to
0edf425
Compare
Author
lithdew
force-pushed
the
main
branch
2 times, most recently
from
February 6, 2026 15:11
e55e48d to
33be4f9
Compare
Adds support for Anthropic's search result blocks and custom content
documents, enabling Claude to cite specific passages from user-provided
content.
Search results can be passed as file parts with provider options
specifying `type: 'search_result'` along with a source URL. Custom
content documents use `source: { type: 'content', content: [...] }`
for pre-chunked text that Claude can cite directly.
Two new citation location types are now parsed in responses:
`search_result_location` and `content_block_location`. These return
as `source` parts with provider metadata containing the cited text,
source URL, search result index, and block ranges.
Includes streaming support with full test coverage for both
generateText and streamText flows. Documentation updated with
usage examples and configuration options.
Author
|
Any chance for review? 👀 |
Open
5 tasks done
Collaborator
|
Superseded by #16740. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Anthropic's API supports search result blocks and custom content documents that enable Claude to cite specific passages in responses. This functionality was not exposed through the AI SDK, limiting users who want to build RAG applications with proper source attribution.
https://platform.claude.com/docs/en/build-with-claude/search-results
https://platform.claude.com/docs/en/build-with-claude/citations#custom-content-documents
Summary
Adds support for Anthropic's search result blocks and custom content documents, enabling Claude to cite specific passages from user-provided content.
Search results can be passed as file parts with provider options specifying
type: 'search_result'along with a source URL. Custom content documents usesource: { type: 'content', content: [...] }for pre-chunked text that Claude can cite directly.Two new citation location types are now parsed in responses:
search_result_locationandcontent_block_location. These return assourceparts with provider metadata containing the cited text, source URL, search result index, and block ranges.Includes streaming support with full test coverage for both generateText and streamText flows. Documentation updated with usage examples and configuration options.
Manual Verification
Ran the example files to verify end-to-end functionality:
pnpm tsx src/generate-text/anthropic-search-results.tspnpm tsx src/stream-text/anthropic-search-results.tspnpm tsx src/generate-text/anthropic-custom-content-documents.tspnpm tsx src/stream-text/anthropic-custom-content-documents.tsConfirmed that:
Checklist
pnpm changesetin the project root)Future Work
Add support for returning
search_resultblocks from tool calls. Need to double-check if custom content documents can be returned from tool calls. Will be done in a subsequent PR.