fix: revert to stable baseline with minimal targeted improvements
This commit is contained in:
+8
-57
@@ -149,13 +149,8 @@ async function runOllamaLoop(ctx: AgentRunContext): Promise<AgentResult> {
|
||||
let calledOutputTool = false;
|
||||
let addedContinueNudge = false;
|
||||
let reportProgressCount = 0;
|
||||
let selectedModeName = "";
|
||||
// Accumulates content from each read_file call (all ranges) so that when
|
||||
// tool messages are pruned, the model retains the diff content it read.
|
||||
// Keyed by "path:start:end" so multiple ranges of the same file are kept.
|
||||
const readFileLog: string[] = [];
|
||||
let injectedFileReadSummary = false;
|
||||
let editCommentCount = 0;
|
||||
let selectedModeName = "";
|
||||
|
||||
while (iterations < MAX_ITERATIONS) {
|
||||
iterations++;
|
||||
@@ -211,23 +206,6 @@ async function runOllamaLoop(ctx: AgentRunContext): Promise<AgentResult> {
|
||||
);
|
||||
if (promptTokens > numCtx * 0.77) {
|
||||
messages = pruneToolMessages(messages);
|
||||
// Inject accumulated diff content as a user message (survives pruning).
|
||||
// Only inject once — subsequent prune events leave this message intact.
|
||||
if (readFileLog.length > 0 && !injectedFileReadSummary) {
|
||||
injectedFileReadSummary = true;
|
||||
const combined = readFileLog.join("\n---\n").slice(0, 10000);
|
||||
const isReview =
|
||||
selectedModeName === "Review" || selectedModeName === "IncrementalReview";
|
||||
messages.push({
|
||||
role: "user",
|
||||
content:
|
||||
`Diff content read earlier (preserved after context pruning):\n\n${combined}\n\n` +
|
||||
(isReview
|
||||
? "Now call create_pull_request_review with your review findings. Do NOT call report_progress."
|
||||
: "Continue the workflow using the content above."),
|
||||
});
|
||||
log.info(`» injected file-read summary: ${readFileLog.length} read(s)`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,20 +286,6 @@ async function runOllamaLoop(ctx: AgentRunContext): Promise<AgentResult> {
|
||||
content: result,
|
||||
});
|
||||
|
||||
// Track every read_file call — accumulate all ranges (same path, different
|
||||
// start/end lines) since the model reads the diff file in multiple chunks.
|
||||
// read_file returns { content: "..." } JSON — extract the actual content.
|
||||
if (toolName === "read_file") {
|
||||
let excerpt: string;
|
||||
try {
|
||||
const parsed = JSON.parse(result) as { content?: string };
|
||||
excerpt = (parsed.content ?? result).slice(0, 500);
|
||||
} catch {
|
||||
excerpt = result.slice(0, 500);
|
||||
}
|
||||
readFileLog.push(excerpt);
|
||||
}
|
||||
|
||||
// After checkout_pr returns, extract and pin the diffPath as a user
|
||||
// message. Only tool messages are pruned — user messages survive context
|
||||
// pressure — so the model retains the exact diff file path and knows how
|
||||
@@ -347,30 +311,17 @@ async function runOllamaLoop(ctx: AgentRunContext): Promise<AgentResult> {
|
||||
}
|
||||
}
|
||||
|
||||
// report_progress is forbidden in Review/IncrementalReview — intercept it.
|
||||
// In other modes, stop after 2+ calls (loop detection).
|
||||
// report_progress called repeatedly means the model is stuck.
|
||||
if (toolName === "report_progress") {
|
||||
const isReview =
|
||||
selectedModeName === "Review" || selectedModeName === "IncrementalReview";
|
||||
if (isReview) {
|
||||
log.info("» report_progress intercepted in Review mode — redirecting");
|
||||
messages.push({
|
||||
role: "user",
|
||||
content:
|
||||
"report_progress is not allowed in Review mode. " +
|
||||
"Call create_pull_request_review now with your findings.",
|
||||
});
|
||||
} else {
|
||||
reportProgressCount++;
|
||||
if (reportProgressCount >= 2) {
|
||||
log.info("» report_progress loop — stopping");
|
||||
await unloadModel(ollama, model);
|
||||
return { success: true };
|
||||
}
|
||||
reportProgressCount++;
|
||||
if (reportProgressCount >= 2) {
|
||||
log.info("» report_progress loop — stopping");
|
||||
await unloadModel(ollama, model);
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
|
||||
// edit_issue_comment called repeatedly means the model is stuck looping.
|
||||
// edit_issue_comment called repeatedly means the model is stuck.
|
||||
if (toolName === "edit_issue_comment") {
|
||||
editCommentCount++;
|
||||
if (editCommentCount >= 2) {
|
||||
|
||||
Reference in New Issue
Block a user