🐛(vercel-sdk) allow tool calls to have no arguments

Some tools might not need arguments because they rely only
on the run context, we can allow that.
This commit is contained in:
Quentin BEY
2025-09-22 22:39:19 +02:00
parent d486661f32
commit 05dceec3e7
2 changed files with 6 additions and 4 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ class ToolCall(BaseModel):
toolCallId: str
toolName: str
args: Dict[str, Any]
args: Optional[Dict[str, Any]] = None
class ToolResult(BaseModel):
@@ -38,7 +38,7 @@ class ToolResult(BaseModel):
toolCallId: str
toolName: str
args: Dict[str, Any]
args: Optional[Dict[str, Any]] = None
result: Any
@@ -119,7 +119,7 @@ def model_message_to_ui_message(model_message: ModelMessage) -> UIMessage: # no
raise ValueError(
f"Unsupported UserContent in UserPromptPart: {type(c)}"
)
elif isinstance(part, TextPart):
elif isinstance(part, TextPart) and part.content:
parts.append(TextUIPart(type="text", text=part.content))
elif isinstance(part, ToolReturnPart):
pass
@@ -188,7 +188,9 @@ def model_message_to_ui_message(model_message: ModelMessage) -> UIMessage: # no
state="call",
toolCallId=part.tool_call_id,
toolName=part.tool_name,
args=json.loads(part.args) if isinstance(part.args, str) else part.args,
args=json.loads(part.args)
if isinstance(part.args, str)
else part.args or {},
),
)
)