Skip to content

Commit 10b85b2

Browse files
jacoblee93FilipZmijewski
authored andcommitted
fix(core): Loosen return type of withConfig, fix tracing for nested tool calls (langchain-ai#6847)
1 parent 012a6c7 commit 10b85b2

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

langchain-core/src/runnables/base.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export abstract class Runnable<
174174
*/
175175
withConfig(
176176
config: RunnableConfig
177-
): RunnableBinding<RunInput, RunOutput, CallOptions> {
177+
): Runnable<RunInput, RunOutput, CallOptions> {
178178
// eslint-disable-next-line @typescript-eslint/no-use-before-define
179179
return new RunnableBinding({
180180
bound: this,
@@ -1236,7 +1236,7 @@ export class RunnableBinding<
12361236

12371237
withConfig(
12381238
config: RunnableConfig
1239-
): RunnableBinding<RunInput, RunOutput, CallOptions> {
1239+
): Runnable<RunInput, RunOutput, CallOptions> {
12401240
// eslint-disable-next-line @typescript-eslint/no-explicit-any
12411241
return new (this.constructor as any)({
12421242
bound: this.bound,
@@ -2328,7 +2328,6 @@ export class RunnableLambda<RunInput, RunOutput> extends Runnable<
23282328
try {
23292329
let output = await this.func(input, {
23302330
...childConfig,
2331-
config: childConfig,
23322331
});
23332332
if (output && Runnable.isRunnable(output)) {
23342333
if (config?.recursionLimit === 0) {

langchain-core/src/tools/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ export function tool<
606606
const childConfig = patchConfig(config, {
607607
callbacks: runManager?.getChild(),
608608
});
609-
void AsyncLocalStorageProviderSingleton.getInstance().run(
609+
void AsyncLocalStorageProviderSingleton.runWithConfig(
610610
childConfig,
611611
async () => {
612612
try {

langchain-core/src/tools/tests/tools.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test, expect } from "@jest/globals";
22
import { z } from "zod";
3+
34
import { DynamicStructuredTool, tool } from "../index.js";
45
import { ToolMessage } from "../../messages/tool.js";
56

0 commit comments

Comments
 (0)