Skip to content

Commit

Permalink
feat(core): Allow passing returnDirect in tool wrapper params (langch…
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 authored Jan 25, 2025
1 parent 1cb4e29 commit 0bc8130
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion langchain-core/src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ export interface StructuredToolInterface<T extends ZodObjectAny = ZodObjectAny>
*/
description: string;

/**
* Whether to return the tool's output directly.
*
* Setting this to true means that after the tool is called,
* an agent should stop looping.
*/
returnDirect: boolean;
}

Expand All @@ -133,9 +139,14 @@ export abstract class StructuredTool<

abstract schema: T | z.ZodEffects<T>;

/**
* Whether to return the tool's output directly.
*
* Setting this to true means that after the tool is called,
* an agent should stop looping.
*/
returnDirect = false;

// TODO: Make default in 0.3
verboseParsingErrors = false;

get lc_namespace() {
Expand Down Expand Up @@ -347,6 +358,12 @@ export abstract class Tool extends StructuredTool<ZodObjectAny> {
export interface BaseDynamicToolInput extends ToolParams {
name: string;
description: string;
/**
* Whether to return the tool's output directly.
*
* Setting this to true means that after the tool is called,
* an agent should stop looping.
*/
returnDirect?: boolean;
}

Expand Down Expand Up @@ -540,6 +557,13 @@ interface ToolWrapperParams<
* @default "content"
*/
responseFormat?: ResponseFormat;
/**
* Whether to return the tool's output directly.
*
* Setting this to true means that after the tool is called,
* an agent should stop looping.
*/
returnDirect?: boolean;
}

/**
Expand Down

0 comments on commit 0bc8130

Please sign in to comment.