Skip to content

Conversation

@narengogi
Copy link
Collaborator

No description provided.

@narengogi narengogi changed the title add citations types to bedrock contentItem citations for anthropic models and bedrock models Nov 3, 2025
@matter-code-review
Copy link
Contributor

Code Quality new feature

Summary By MatterAI MatterAI logo

🔄 What Changed

Added support for citationsContent and toolResult fields in the Bedrock ContentItem type definition. The change introduces structured citation metadata including document location (char, chunk, page), source content, title, and associated text content. Also added optional tool execution result tracking via toolUseId, status, and output.

🔍 Impact of the Change

Enables rich citation handling and tool response tracking in AI-generated content from Bedrock models. Supports traceability of model outputs to source documents and improves transparency in RAG workflows. Non-breaking addition that enhances downstream processing capabilities.

📁 Total Files Changed

File ChangeLog
Types Update src/providers/bedrock/types.ts Added citationsContent for citation metadata and toolResult for tool execution status in ContentItem interface

🧪 Test Added/Recommended

Recommended

  • Unit tests validating schema conformance for citationsContent with nested location types
  • Integration tests verifying citation payload round-tripping through Bedrock API
  • Type-check assertions ensuring optional nature of new fields

🔒 Security Vulnerabilities

N/A

⏳ Estimated code review effort

LOW (~7 minutes)

Tip

Quality Recommendations

  1. Add explicit typing for content: any in toolResult to improve type safety

  2. Include validation logic for documentIndex bounds when processing citations

  3. Add JSDoc comments describing usage of citationsContent for developer clarity

♫ Tanka Poem

New fields take flight,
Citations trace back to source,
Truth in each response,
Tool results mark their passage—
AI speaks with provenance. 🌐📚

Sequence Diagram

sequenceDiagram
    participant Client
    participant Bedrock
    participant ContentProcessor

    Client->>Bedrock: GenerateContent(request)
    Bedrock->>ContentProcessor: processContentItem(item)
    ContentProcessor->>ContentProcessor: parse citationsContent?.citations[]
    ContentProcessor->>ContentProcessor: validate documentIndex, start, end ranges
    ContentProcessor-->>Bedrock: structured response with citations
    Bedrock-->>Client: response with citation metadata

    Note right of ContentProcessor: Extracts and validates
source attribution from\nAI-generated content
Loading

@matter-code-review
Copy link
Contributor

✅ Reviewed the changes: Adding new types for toolResult and citationsContent to enhance Bedrock content items. Review focuses on type safety and clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant