-
Notifications
You must be signed in to change notification settings - Fork 18.8k
feat(core): (v1) restore separate type for AIMessage.tool_calls
#32668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): (v1) restore separate type for AIMessage.tool_calls
#32668
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
CodSpeed WallTime Performance ReportMerging #32668 will degrade performances by 28.39%Comparing
|
Benchmark | BASE |
HEAD |
Change | |
---|---|---|---|---|
❌ | test_import_time[HumanMessage] |
211.8 ms | 295.8 ms | -28.39% |
Footnotes
CodSpeed Instrumentation Performance ReportMerging #32668 will degrade performances by 60.72%Comparing Summary
Benchmarks breakdown
|
AIMessage.tool_calls
@@ -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] |
There was a problem hiding this comment.
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"}] |
There was a problem hiding this comment.
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?
"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: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.