Skip to content

Bedrock converseStream returns citation chunks with empty "location": { "web": {} } instead of proper document locations

0

I’m seeing an issue with Amazon Bedrock Converse Stream (converseStream / ConverseStreamCommand) where citations returned in streaming mode do not contain the correct document location information.

When calling Bedrock with enabled citations, input including documents, using boto3 converse_stream or JS SDK ConverseStreamCommand, the streamed output contains citation chunks shaped like:

{
  "citation": {
    "title": "My Document",
    "sourceContent": [{ "text": "..." }],
    "location": { "web": {} }
  }
}

However, based on the API documentation and on previous SDK versions, the location field should contain actual document locations, such as:

"location": {
  "documentChar": {
    "documentIndex": 0,
    "start": 0,
    "end": 50
  }
}

or

"location": {
  "documentPage": {
    "documentIndex": 0,
    "pageNumber": 1
  }
}

converseStream should return citations with correct document location metadata (documentChar, documentPage, or documentChunk) for uploaded documents, exactly as the non-streaming converse API does.

All streamed citation chunks contain location: { "web": {} }. This happens regardless of which model is used. The issue occurs in both JS and Python SDKs, which implies the issue may be on the service side rather than the SDK.

Sample python code to reproduce:

import json
import boto3

br = boto3.client("bedrock-runtime", region_name="eu-central-1")

def main():
    with open("sample.txt", "r", encoding="utf-8") as f:
        doc_text = f.read()

    payload = {
        "modelId": "eu.anthropic.claude-sonnet-4-20250514-v1:0",
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "document": {
                            "name": "Example Document",
                            "format": "txt",
                            "source": {"text": doc_text},
                            "citations": {"enabled": True},
                        }
                    },
                    {"text": "what is this document about?"},
                ],
            }
        ],
    }

    response = br.converse_stream(**payload)

    stream = response.get("stream")
    for event in stream:
        print("=== event ===")
        print(json.dumps(event, indent=2))


if __name__ == "__main__":
    main()

We receive:

{
  "contentBlockDelta": {
    "delta": {
      "citation": {
        "title": "Example Document",
        "sourceContent": [
          {
            "text": "This is an example document content used for testing document upload functionality in the chat application."
          }
        ],
        "location": {
          "web": {} # instead of documentChar: { ... }
         }
      }
    },
    "contentBlockIndex": 1
  }
}

I already raised an issue with AWS Support, however haven't heard back yet.

asked a year ago229 views

1 Answer
0

You're correct that there appears to be an inconsistency in how citation locations are returned in the streaming response from Amazon Bedrock's converseStream operation.

Based on the Amazon Bedrock API documentation, citation locations should indeed contain specific document location information such as documentChar, documentPage, or documentChunk depending on the document type and indexing method. These location types provide precise information about where in the document the cited content was found.

For documentChar locations, you should expect to see fields like documentIndex, start, and end character positions. For documentPage locations, you would see documentIndex along with start and end page numbers. Similarly, documentChunk locations would include documentIndex with start and end chunk identifiers.

The empty "web": {} location you're receiving in the streaming response doesn't match the expected format for document citations. This appears to be inconsistent with how the non-streaming API behaves and with what the API documentation describes.

Since you're experiencing this issue across both JavaScript and Python SDKs, it does suggest this might be a service-side issue rather than an SDK-specific problem. Continuing to work with AWS Support is the right approach, as they would need to investigate why the citation location information is not being properly populated in the streaming response.
Sources
Citation - Amazon Bedrock
CitationsDelta - Amazon Bedrock
CitationLocation - Amazon Bedrock
count_tokens - Boto3 1.40.63 documentation

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.