mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Summarize tool call outputs using tool specific summarizers (#3745)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { FunctionDeclaration, PartListUnion, Schema } from '@google/genai';
|
||||
import { Summarizer, defaultSummarizer } from '../utils/summarizer.js';
|
||||
|
||||
/**
|
||||
* Interface representing the base Tool functionality
|
||||
@@ -43,6 +44,16 @@ export interface Tool<
|
||||
*/
|
||||
canUpdateOutput: boolean;
|
||||
|
||||
/**
|
||||
* A function that summarizes the result of the tool execution.
|
||||
*/
|
||||
summarizer?: Summarizer;
|
||||
|
||||
/**
|
||||
* Whether the tool's display output should be summarized
|
||||
*/
|
||||
shouldSummarizeDisplay?: boolean;
|
||||
|
||||
/**
|
||||
* Validates the parameters for the tool
|
||||
* Should be called from both `shouldConfirmExecute` and `execute`
|
||||
@@ -98,6 +109,8 @@ export abstract class BaseTool<
|
||||
* @param isOutputMarkdown Whether the tool's output should be rendered as markdown
|
||||
* @param canUpdateOutput Whether the tool supports live (streaming) output
|
||||
* @param parameterSchema JSON Schema defining the parameters
|
||||
* @param summarizer Function to summarize the tool's output
|
||||
* @param shouldSummarizeDisplay Whether the tool's display output should be summarized
|
||||
*/
|
||||
constructor(
|
||||
readonly name: string,
|
||||
@@ -106,6 +119,8 @@ export abstract class BaseTool<
|
||||
readonly parameterSchema: Schema,
|
||||
readonly isOutputMarkdown: boolean = true,
|
||||
readonly canUpdateOutput: boolean = false,
|
||||
readonly summarizer: Summarizer = defaultSummarizer,
|
||||
readonly shouldSummarizeDisplay: boolean = false,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -173,6 +188,11 @@ export abstract class BaseTool<
|
||||
}
|
||||
|
||||
export interface ToolResult {
|
||||
/**
|
||||
* A short, one-line summary of the tool's action and result.
|
||||
* e.g., "Read 5 files", "Wrote 256 bytes to foo.txt"
|
||||
*/
|
||||
summary?: string;
|
||||
/**
|
||||
* Content meant to be included in LLM history.
|
||||
* This should represent the factual outcome of the tool execution.
|
||||
|
||||
Reference in New Issue
Block a user