Skip to content

Commit 77eb116

Browse files
authored
Make wrapToolCall asynchronous for error handling (#1374)
## Overview Make wrapToolCall asynchronous for error handling ## Type of change Fix bug ## Related issues/PRs <!-- Link to related issues, feature PRs, or discussions (if applicable) To automatically close an issue when this PR is merged, use closing keywords: - "closes #123" or "fixes #123" or "resolves #123" For regular references without auto-closing, just use: - "#123" or "See issue #123" Examples: - closes #456 (will auto-close issue #456 when PR is merged) - See #789 for context (will reference but not auto-close issue #789) --> - GitHub issue: - Feature PR: <!-- For LangChain employees, if applicable: --> - Linear issue: - Slack thread: ## Checklist <!-- Put an 'x' in all boxes that apply --> - [x] I have read the [contributing guidelines](README.md) - [x] I have tested my changes locally using `docs dev` - [x] All code examples have been tested and work correctly - [x] I have used **root relative** paths for internal links - [x] I have updated navigation in `src/docs.json` if needed - I have gotten approval from the relevant reviewers - (Internal team members only / optional) I have created a preview deployment using the [Create Preview Branch workflow](https://github.com/langchain-ai/docs/actions/workflows/create-preview-branch.yml) ## Additional notes <!-- Any other information that would be helpful for reviewers -->
1 parent 1f32654 commit 77eb116

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/oss/langchain/agents.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ import { createAgent, createMiddleware, ToolMessage } from "langchain";
341341

342342
const handleToolErrors = createMiddleware({
343343
name: "HandleToolErrors",
344-
wrapToolCall: (request, handler) => {
344+
wrapToolCall: async (request, handler) => {
345345
try {
346-
return handler(request);
346+
return await handler(request);
347347
} catch (error) {
348348
// Return a custom error message to the model
349349
return new ToolMessage({

0 commit comments

Comments
 (0)