chore: bump context window to match what zed uses
This commit is contained in:
+3
-2
@@ -120,7 +120,7 @@ async function runOllamaLoop(ctx: AgentRunContext): Promise<AgentResult> {
|
||||
keep_alive: "10m",
|
||||
options: {
|
||||
think: true,
|
||||
num_ctx: 32768,
|
||||
num_ctx: 262144,
|
||||
} as Record<string, unknown>,
|
||||
});
|
||||
} catch (err) {
|
||||
@@ -216,7 +216,8 @@ async function runOllamaLoop(ctx: AgentRunContext): Promise<AgentResult> {
|
||||
const parsed = JSON.parse(
|
||||
typeof lastToolMsg.content === "string" ? lastToolMsg.content : "",
|
||||
);
|
||||
if (typeof parsed?.modeName === "string") selectedMode = parsed.modeName;
|
||||
if (typeof parsed?.modeName === "string")
|
||||
selectedMode = parsed.modeName;
|
||||
} catch {
|
||||
// best-effort
|
||||
}
|
||||
|
||||
+19
-5
@@ -3,6 +3,9 @@ import { type } from "arktype";
|
||||
import type { ToolContext } from "./server.ts";
|
||||
import { execute, tool } from "./shared.ts";
|
||||
|
||||
/** Hard cap on returned content to avoid flooding the model's context window. */
|
||||
const MAX_CHARS = 6000;
|
||||
|
||||
export const ReadFileParams = type({
|
||||
path: type.string.describe("absolute path to the file to read"),
|
||||
"start_line?": type.number.describe("start line, 1-based inclusive (default: 1)"),
|
||||
@@ -14,6 +17,8 @@ export function ReadFileTool(_ctx: ToolContext) {
|
||||
name: "read_file",
|
||||
description:
|
||||
"Read lines from a file. Use this to read sections of the PR diff returned by checkout_pr. " +
|
||||
`Returns at most ${MAX_CHARS} characters — use narrow line ranges to stay within budget. ` +
|
||||
"Read selectively: only the files most relevant to the review, not the entire diff at once. " +
|
||||
"Example: `read_file({ path: diffPath, start_line: 5, end_line: 42 })`.",
|
||||
parameters: ReadFileParams,
|
||||
execute: execute(async ({ path, start_line, end_line }) => {
|
||||
@@ -25,14 +30,23 @@ export function ReadFileTool(_ctx: ToolContext) {
|
||||
throw new Error(`failed to read ${path}: ${msg}`);
|
||||
}
|
||||
|
||||
if (start_line === undefined && end_line === undefined) {
|
||||
return { content };
|
||||
}
|
||||
|
||||
const lines = content.split("\n");
|
||||
const start = Math.max(0, (start_line ?? 1) - 1);
|
||||
const end = Math.min(lines.length, end_line ?? lines.length);
|
||||
return { content: lines.slice(start, end).join("\n") };
|
||||
const slice = lines.slice(start, end).join("\n");
|
||||
|
||||
if (slice.length <= MAX_CHARS) {
|
||||
return { content: slice };
|
||||
}
|
||||
|
||||
const truncated = slice.slice(0, MAX_CHARS);
|
||||
const linesShown = truncated.split("\n").length;
|
||||
const linesTotal = end - start;
|
||||
return {
|
||||
content: truncated,
|
||||
truncated: true,
|
||||
note: `Output capped at ${MAX_CHARS} chars (showed ${linesShown}/${linesTotal} lines). Use a narrower line range to read the rest.`,
|
||||
};
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user