fix: if no stop reason, attempt to resume from background mode (#56)

This commit is contained in:
Charles Packer
2025-11-04 11:20:58 -08:00
committed by GitHub
parent 864c67248b
commit 42eb671bf4
9 changed files with 91 additions and 28 deletions

View File

@@ -13,7 +13,7 @@ import { getModelUpdateArgs } from "./agent/model";
import { SessionStats } from "./agent/stats";
import { createBuffers, toLines } from "./cli/helpers/accumulator";
import { safeJsonParseOr } from "./cli/helpers/safeJsonParse";
import { drainStream } from "./cli/helpers/stream";
import { drainStreamWithResume } from "./cli/helpers/stream";
import { settingsManager } from "./settings-manager";
import { checkToolPermission, executeTool } from "./tools/manager";
@@ -142,7 +142,7 @@ export async function handleHeadlessCommand(argv: string[], model?: string) {
const initEvent = {
type: "init",
agent_id: agent.id,
model: agent.llmConfig?.model,
model: agent.llm_config?.model,
tools: agent.tools?.map((t) => t.name) || [],
};
console.log(JSON.stringify(initEvent));
@@ -228,7 +228,7 @@ export async function handleHeadlessCommand(argv: string[], model?: string) {
// no-op
}
} else {
await drainStream(approvalStream, createBuffers(), () => {});
await drainStreamWithResume(approvalStream, createBuffers(), () => {});
}
}
};
@@ -453,8 +453,8 @@ export async function handleHeadlessCommand(argv: string[], model?: string) {
);
markCurrentLineAsFinished(buffers);
} else {
// Normal mode: use drainStream
const result = await drainStream(
// Normal mode: use drainStreamWithResume
const result = await drainStreamWithResume(
stream,
buffers,
() => {}, // No UI refresh needed in headless mode