The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
feat(core): support AWS Bedrock `document` content blocks in `msg_content_output` (#32799)
Adithya1617f5bd00d1f191
diff --git a/libs/core/langchain_core/tools/base.py b/libs/core/langchain_core/tools/base.pyindex c4de10ddeb..5f09665c79 100644--- a/libs/core/langchain_core/tools/base.py+++ b/libs/core/langchain_core/tools/base.py@@ -81,6 +81,7 @@ TOOL_MESSAGE_BLOCK_TYPES = ("json","search_result","custom_tool_call_output",+ "document",)diff --git a/libs/core/tests/unit_tests/test_tools.py b/libs/core/tests/unit_tests/test_tools.pyindex aabc7e35ff..b296608120 100644--- a/libs/core/tests/unit_tests/test_tools.py+++ b/libs/core/tests/unit_tests/test_tools.py@@ -52,6 +52,7 @@ from langchain_core.tools import (tool,)from langchain_core.tools.base import (+ TOOL_MESSAGE_BLOCK_TYPES,ArgsSchema,InjectedToolArg,InjectedToolCallId,@@ -1413,6 +1414,29 @@ def test_tool_call_input_tool_message_output() -> None:tool.invoke(tool_call)[email protected]("block_type", [*TOOL_MESSAGE_BLOCK_TYPES, "bad"])+def test_tool_content_block_output(block_type: str) -> None:+ @tool+ def my_tool(query: str) -> list[dict[str, Any]]:+ """Test tool."""+ return [{"type": block_type, "foo": "bar"}]++ tool_call = {+ "type": "tool_call",+ "name": "my_tool",+ "args": {"query": "baz"},+ "id": "call_abc123",+ }++ result = my_tool.invoke(tool_call)+ assert isinstance(result, ToolMessage)++ if block_type in TOOL_MESSAGE_BLOCK_TYPES:+ assert result.content == [{"type": block_type, "foo": "bar"}]+ else:+ assert result.content == '[{"type": "bad", "foo": "bar"}]'++class _MockStructuredToolWithRawOutput(BaseTool):name: str = "structured_api"args_schema: type[BaseModel] = _MockSchema