diff --git a/langchain-core/src/runnables/base.ts b/langchain-core/src/runnables/base.ts index f5cba453fb27..4423c0c72132 100644 --- a/langchain-core/src/runnables/base.ts +++ b/langchain-core/src/runnables/base.ts @@ -6,7 +6,6 @@ import { type TraceableFunction, isTraceableFunction, } from "langsmith/singletons/traceable"; -import { zodToJsonSchema } from "zod-to-json-schema"; import type { RunnableInterface, RunnableBatchOptions } from "./types.js"; import { CallbackManagerForChainRun } from "../callbacks/manager.js"; import { @@ -1088,7 +1087,7 @@ export abstract class Runnable< * * @param fields * @param {string | undefined} [fields.name] The name of the tool. If not provided, it will default to the name of the runnable. - * @param {string | undefined} [fields.description] The description of the tool. If not provided, it will default to `Takes {schema}` where `schema` is a JSON string representation of the input schema. + * @param {string | undefined} [fields.description] The description of the tool. * @param {z.ZodType} [fields.schema] The Zod schema for the input of the tool. Infers the Zod type from the input type of the runnable. * @returns {RunnableToolLike, RunOutput>} An instance of `RunnableToolLike` which is a runnable that can be used as a tool. */ @@ -2842,15 +2841,6 @@ export class RunnableToolLike< } } -/** - * Generate a placeholder description of a runnable - */ -const _getDescriptionFromRunnable = ( - schema: RunInput -): string => { - return `Takes ${JSON.stringify(schema, null, 2)}`; -}; - /** * Given a runnable and a Zod schema, convert the runnable to a tool. * @@ -2860,7 +2850,7 @@ const _getDescriptionFromRunnable = ( * @param {Runnable} runnable The runnable to convert to a tool. * @param fields * @param {string | undefined} [fields.name] The name of the tool. If not provided, it will default to the name of the runnable. - * @param {string | undefined} [fields.description] The description of the tool. If not provided, it will default to `Takes {schema}` where `schema` is a JSON string representation of the input schema. + * @param {string | undefined} [fields.description] The description of the tool. * @param {z.ZodType} [fields.schema] The Zod schema for the input of the tool. Infers the Zod type from the input type of the runnable. * @returns {RunnableToolLike, RunOutput>} An instance of `RunnableToolLike` which is a runnable that can be used as a tool. */ @@ -2872,15 +2862,13 @@ export function convertRunnableToTool( schema: z.ZodType; } ): RunnableToolLike, RunOutput> { - const description = - fields.description ?? - _getDescriptionFromRunnable(zodToJsonSchema(fields.schema)); + const { description, schema } = fields; const name = fields.name ?? runnable.getName(); return new RunnableToolLike, RunOutput>({ name, description, - schema: fields.schema, + schema, bound: runnable, }); } diff --git a/langchain-core/src/runnables/tests/runnable_tools.test.ts b/langchain-core/src/runnables/tests/runnable_tools.test.ts index f97ecb4c3514..938fde9b8c30 100644 --- a/langchain-core/src/runnables/tests/runnable_tools.test.ts +++ b/langchain-core/src/runnables/tests/runnable_tools.test.ts @@ -17,9 +17,6 @@ test("Runnable asTool works", async () => { expect(tool).toBeInstanceOf(RunnableToolLike); expect(tool.schema).toBe(schema); - expect(tool.description).toBe( - `Takes ${JSON.stringify(zodToJsonSchema(schema), null, 2)}` - ); expect(tool.name).toBe(runnable.getName()); });