Skip to content

Commit 5e389ae

Browse files
gvdongenslinkydeveloper
authored andcommitted
Require tool calls with ID in langchain ext (#199)
(cherry picked from commit 0944e3f)
1 parent cb56e99 commit 5e389ae

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

python/restate/ext/langchain/_middleware.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ async def awrap_tool_call(
114114
request: ToolCallRequest,
115115
handler: Callable[[ToolCallRequest], Awaitable[ToolCallResult]],
116116
) -> ToolCallResult:
117-
tool_call = request.tool_call
118-
tool_call_id: Optional[str] = tool_call.get("id") if isinstance(tool_call, dict) else None
117+
tool_call_id = request.tool_call.get("id")
119118
if tool_call_id is None:
120-
return await handler(request)
119+
return ToolMessage("Function call ID is required for tool invocation. Please set `id` on the ToolCall.")
121120

122121
ctx = current_context()
123122
assert ctx is not None, "RestateMiddleware must run inside a Restate handler"

0 commit comments

Comments
 (0)