Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Allow passing returnDirect in tool wrapper params #7594

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading