Skip to content

@langchain/aws does not properly parse gpt-oss content blocks #9280

@jmroon

Description

@jmroon

Checked other resources

  • This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

import { ChatBedrockConverse } from "@langchain/aws";

const bedrock = new ChatBedrockConverse({
  model: "openai.gpt-oss-120b-1:0",
  region: "us-east-1",
  performanceConfig: {
    latency: 'optimized',
  },
  credentials: {
    accessKeyId: ACCESS_KEY_ID,
    secretAccessKey: SECRET_ACCESS_KEY,
  },
});

const aiMsg = await bedrock.invoke([
  [ "system", "You are a helpful assistant."],
  ["human", "How are you?"],
])
console.log(JSON.stringify(aiMsg.contentBlocks, null, 2));

Error Message and Stack Trace (if applicable)

No response

Description

ReasoningContentBlock is not being correctly inferred from AWS Bedrock gpt-oss model responses.

Actual response:

[
  {
    "type": "non_standard",
    "value": {
      "type": "reasoning_content",
      "reasoningText": {
        "text": "The user asks \"How are you?\" It's a casual question. I respond politely."
      }
    }
  },
  {
    "type": "text",
    "text": "I'm doing great, thank you! How can I assist you today?"
  }
]

Expected response:

[
  {
    "type": "reasoning",
     "reasoning": "The user asks \"How are you?\" It's a casual question. I respond politely."
  },
  {
    "type": "text",
    "text": "I'm doing great, thank you! How can I assist you today?"
  }
]

System Info

[email protected]
mac
Node v23.11.1
pnpm 10.19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions