langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
95.32k stars 15.46k forks source link

Agents with different tools not working on bedrock #27002

Open tomaszbk opened 1 month ago

tomaszbk commented 1 month ago

Checked other resources

Example Code

from langchain_aws import ChatBedrockConverse

llm = ChatBedrockConverse(
        model=AWS_BEDROCK_MODEL,
        region_name=AWS_BEDROCK_REGION,
    )

orchestration_tools = [choose_action]
orchestration_tool_node = ToolNode(orchestration_tools)
orchestration_model = llm.bind_tools(orchestration_tools)

conversation_model = llm

products_tools = [get_products, get_product_details]
products_tools_node = ToolNode(products_tools)
products_model = llm.bind_tools(products_tools)

purchase_tools = [make_purchase, get_user_data]
purchase_tools_node = ToolNode(purchase_tools)
purchase_model = llm.bind_tools(purchase_tools)

Error Message and Stack Trace (if applicable)

botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the Converse operation: The toolConfig field must be defined when using toolUse and toolResult content blocks.

Description

Some agents have tools binded and others doesn't. When the chat history with tool calls is received in an agent without tools (or don't know if same would happen in one that has tools but different ones), the specified error appears

System Info

"boto3>=1.35.29",
"fastapi>=0.115.0",
"langchain-aws>=0.2.1",
"langgraph>=0.2.28",
"pydantic-settings>=2.5.2",
"pydantic>=2.9.2",
"python-multipart>=0.0.11",
"uvicorn>=0.31.0"
j10sanders commented 1 month ago

Same issue for me, without using langchain - just using bedrock sdk. So it's a bedrock issue unfortunately

dlqqq commented 1 month ago

Can somebody please transfer this issue to langchain-ai/langchain-aws?