Skip to content

Conversation

ccurme
Copy link
Collaborator

@ccurme ccurme commented Aug 25, 2025

"type" needs to be a required key for content blocks, including tool calls in content blocks, for type discrimination.

This has not a required key for the tool calls in AIMessage.tool_calls. If we require that content ToolCall and .tool_calls ToolCall both require "type", we introduce type errors in user code:

msg.tool_calls = [{"name": "foo", "args": {"a": "b"}, "id": "abc-123"}]

Any pydantic classes expecting tool calls would also raise validation errors if "type" is not provided— I realized this issue when this happened to some test classes in langgraph.

For now, we restore the old type, so that for both AIMessage.tool_calls and AIMessage.tool_call_chunks we have separate types that do not require the "type" key.

@ccurme ccurme requested a review from eyurtsev as a code owner August 25, 2025 13:15
Copy link

vercel bot commented Aug 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchain Ignored Ignored Preview Aug 25, 2025 1:18pm

Copy link

codspeed-hq bot commented Aug 25, 2025

CodSpeed WallTime Performance Report

Merging #32668 will degrade performances by 28.39%

Comparing cc/1.0/standard_content_tc_type (6fecdf1) with cc/1.0/standard_content (d111965)1

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

❌ 1 regressions
✅ 12 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_import_time[HumanMessage] 211.8 ms 295.8 ms -28.39%

Footnotes

  1. No successful run was found on cc/1.0/standard_content (26833f2) during the generation of this report, so 823c15c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link

codspeed-hq bot commented Aug 25, 2025

CodSpeed Instrumentation Performance Report

Merging #32668 will degrade performances by 60.72%

Comparing cc/1.0/standard_content_tc_type (6fecdf1) with cc/1.0/standard_content (d111965)

Summary

⚡ 1 improvements
❌ 1 (👁 1) regressions
✅ 12 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
👁 test_stream_time 15.9 ms 40.5 ms -60.72%
test_stream_time 1,209.3 ms 942.3 ms +28.35%

@ccurme ccurme merged commit 62d746e into cc/1.0/standard_content Aug 25, 2025
228 of 231 checks passed
@ccurme ccurme deleted the cc/1.0/standard_content_tc_type branch August 25, 2025 13:37
@mdrxy mdrxy changed the title feat(core): (v1) restore separate type for AIMessage.tool_calls feat(core): (v1) restore separate type for AIMessage.tool_calls Aug 25, 2025
@mdrxy mdrxy added this to the v1 milestone Aug 25, 2025
@mdrxy mdrxy added the core Related to the package `langchain-core` label Aug 25, 2025
@@ -255,9 +255,9 @@ def content_blocks(self) -> list[types.ContentBlock]:
"args": tool_call["args"],
}
if "index" in tool_call:
tool_call_block["index"] = tool_call["index"]
tool_call_block["index"] = tool_call["index"] # type: ignore[typeddict-item]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ewwwwwwwwwwwww

assert msg.tool_calls[0]["type"] == "tool_call"

# Test we can assign without adding type key
msg.tool_calls = [{"name": "bar", "args": {"c": "d"}, "id": "def"}]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assignment doesn't add a type key right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to the package `langchain-core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants