mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 11:41:04 +00:00
Fix Gemini Code's (GC) smarts.
- The tl;dr; is that GC couldn't see what the user was saying when tool call events happened in response. The rason why this was happening was because we were instantly invoking tools that the model told us to invoke and then instantly re-requesting. This resulted in the bug because the genai APIs can't update the chat history before a full response has been completed (doesn't know how to update if it's incomplete). - To address the above issue I had to do quite the large refactor. The gist is that now turns truly drive everything on the server (vs. a server client split). This ensured that when we got tool invocations we could control when/how re-requesting would happen and then also ensure that history was updated. This change also meant that the server would act as an event publisher to enable the client to react to events rather than try and weave in complex logic between the events. - A BIG change that this changeset incudes is the removal of all of the CLI tools in favor of the server tools. - Removed some dead code as part of this - **NOTE: Confirmations are still broken (they were broken prior to this); however, I've set them up to be able to work in the future, I'll dot hat in a follow up to be less breaking to others.** Fixes https://b.corp.google.com/issues/412320087
This commit is contained in:
parent
e351baf10f
commit
81f0f618f7
27 changed files with 1283 additions and 2331 deletions
|
|
@ -33,7 +33,7 @@ export interface ReadFileToolParams {
|
|||
/**
|
||||
* Implementation of the ReadFile tool logic
|
||||
*/
|
||||
export class ReadFileLogic extends BaseTool<ReadFileToolParams, ToolResult> {
|
||||
export class ReadFileTool extends BaseTool<ReadFileToolParams, ToolResult> {
|
||||
static readonly Name: string = 'read_file';
|
||||
private static readonly DEFAULT_MAX_LINES = 2000;
|
||||
private static readonly MAX_LINE_LENGTH = 2000;
|
||||
|
|
@ -41,9 +41,9 @@ export class ReadFileLogic extends BaseTool<ReadFileToolParams, ToolResult> {
|
|||
|
||||
constructor(rootDirectory: string) {
|
||||
super(
|
||||
ReadFileLogic.Name,
|
||||
'', // Display name handled by CLI wrapper
|
||||
'', // Description handled by CLI wrapper
|
||||
ReadFileTool.Name,
|
||||
'ReadFile',
|
||||
'Reads and returns the content of a specified file from the local filesystem. Handles large files by allowing reading specific line ranges.',
|
||||
{
|
||||
properties: {
|
||||
path: {
|
||||
|
|
@ -236,16 +236,15 @@ export class ReadFileLogic extends BaseTool<ReadFileToolParams, ToolResult> {
|
|||
const startLine = params.offset || 0;
|
||||
const endLine = params.limit
|
||||
? startLine + params.limit
|
||||
: Math.min(startLine + ReadFileLogic.DEFAULT_MAX_LINES, lines.length);
|
||||
: Math.min(startLine + ReadFileTool.DEFAULT_MAX_LINES, lines.length);
|
||||
const selectedLines = lines.slice(startLine, endLine);
|
||||
|
||||
let truncated = false;
|
||||
const formattedLines = selectedLines.map((line) => {
|
||||
let processedLine = line;
|
||||
if (line.length > ReadFileLogic.MAX_LINE_LENGTH) {
|
||||
if (line.length > ReadFileTool.MAX_LINE_LENGTH) {
|
||||
processedLine =
|
||||
line.substring(0, ReadFileLogic.MAX_LINE_LENGTH) +
|
||||
'... [truncated]';
|
||||
line.substring(0, ReadFileTool.MAX_LINE_LENGTH) + '... [truncated]';
|
||||
truncated = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue