Skip to content

Commit

Permalink
fix(core): Loosen return type of withConfig, fix tracing for nested t…
Browse files Browse the repository at this point in the history
…ool calls (langchain-ai#6847)
  • Loading branch information
jacoblee93 authored and FilipZmijewski committed Sep 27, 2024
1 parent 012a6c7 commit 10b85b2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions langchain-core/src/runnables/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export abstract class Runnable<
*/
withConfig(
config: RunnableConfig
): RunnableBinding<RunInput, RunOutput, CallOptions> {
): Runnable<RunInput, RunOutput, CallOptions> {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
return new RunnableBinding({
bound: this,
Expand Down Expand Up @@ -1236,7 +1236,7 @@ export class RunnableBinding<

withConfig(
config: RunnableConfig
): RunnableBinding<RunInput, RunOutput, CallOptions> {
): Runnable<RunInput, RunOutput, CallOptions> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return new (this.constructor as any)({
bound: this.bound,
Expand Down Expand Up @@ -2328,7 +2328,6 @@ export class RunnableLambda<RunInput, RunOutput> extends Runnable<
try {
let output = await this.func(input, {
...childConfig,
config: childConfig,
});
if (output && Runnable.isRunnable(output)) {
if (config?.recursionLimit === 0) {
Expand Down
2 changes: 1 addition & 1 deletion langchain-core/src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ export function tool<
const childConfig = patchConfig(config, {
callbacks: runManager?.getChild(),
});
void AsyncLocalStorageProviderSingleton.getInstance().run(
void AsyncLocalStorageProviderSingleton.runWithConfig(
childConfig,
async () => {
try {
Expand Down
1 change: 1 addition & 0 deletions langchain-core/src/tools/tests/tools.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from "@jest/globals";
import { z } from "zod";

import { DynamicStructuredTool, tool } from "../index.js";
import { ToolMessage } from "../../messages/tool.js";

Expand Down

0 comments on commit 10b85b2

Please sign in to comment.