Skip to content

Bedrock converse citations location always points to web #7497

@Mivekk

Description

@Mivekk

Checkboxes for prior research

Describe the bug

When sending pdf documents using the ConverseStreamCommand command instead of receiving DocumentPageLocation I'm always receiving WebLocation as part of the citation chunk response.

It's a recent issue as the last time when I was working on it it returned proper cited page numbers, however now I'm stuck with location: { web: {} }.

Sample request:

    role: 'user',
    content: [
      {
        document: {
          name: 'Argument fragment',
          format: 'pdf',
          source: {
            bytes: Uint8Array(254432) [
               37,  80,  68, 70, 45, 49,  46,  54,  13, 37, 226, 227,
              207, 211,  13, 10, 53, 53,  57,  32,  48, 32, 111,  98,
              106,  32,  60, 60, 47, 76, 105, 110, 101, 97, 114, 105,
              122, 101, 100, 32, 49, 47,  76,  32,  50, 53,  52,  52,
               51,  50,  47, 79, 32, 53,  54,  49,  47, 69,  32,  56,
               52,  52,  56, 57, 47, 78,  32,  49,  48, 47,  84,  32,
               50,  52,  51, 50, 48, 52,  47,  72,  32, 91,  32,  49,
               50,  51,  54, 32, 53, 54,  52,  93,  62, 62,  13, 101,
              110, 100, 111, 98,
              ... 254332 more items
            ]
          },
          citations: { enabled: true }
        }
      },
      { text: 'what is this document about?' },
      { cachePoint: { type: 'default' } }
    ]
  }

Sample citation chunk response:

citations: [
      {
        location: { web: {} },
        sourceContent: [
          {
            text: 'Po...'
          }
        ],
        title: 'Argument fragment'
      },
]

On versions 3.919.0 and below it returns location: { web: { type: 'char_location' } } or location: { web: { type: 'page_location' } } depending on document type instead of actual locations

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v22.17.1

Reproduction Steps

let testMessages = [
  {
    role: "user",
    content: [
      {
        text: "What is this document about?",
      },
      {
        document: {
          name: "Example Document",
          format: "txt",
          source: {
            text: "This is an example document content used for testing document upload functionality in the chat application.",
          },
          citations: { enabled: true },
        },
      },
    ],
  },
];

const streamInput: ConverseStreamCommandInput = {
  modelId: "eu.anthropic.claude-sonnet-4-5-20250929-v1:0",
  messages: testMessages,
};

const command = new ConverseStreamCommand(streamInput);
const client = new BedrockRuntimeClient();
const response = await client.send(command);

stream = new ReadableStream({
  async start(controller) {
    for await (const chunk of response.stream!) {
      console.dir(chunk, { depth: null });
    }
  },
});

Observed Behavior

It returns empty web object as location instead of DocumentCharLocation

{
  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: {} }
      }
    },
    contentBlockIndex: 0
  }
}

Expected Behavior

{
  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: { documentChar: { documentIndex: 0, start: 0, end: 50 } }
      }
    },
    contentBlockIndex: 0
  }
}

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.guidanceGeneral information and guidance, answers to FAQs, or recommended best practices/resources.p1This is a high priority issuepotential-regressionMarking this issue as a potential regression to be checked by team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions