Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(claude): track whether the launch passed --autocompact instead of searching argsKey

AdityaUmale171af020ba90
diff --git a/server/drivers/claude.ts b/server/drivers/claude.ts
index 4c1e560c1e..111c540bd9 100644
--- a/server/drivers/claude.ts
+++ b/server/drivers/claude.ts
@@ -837,7 +837,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
elicit: ReturnType<typeof claudeElicitations>;
mcpConfigPath: string | null;
systemPromptPath: string | null;
- argsKey: string; /** the CLI version whose --help chose the args */ cliVersion: string | null;
+ argsKey: string; /** the CLI version whose --help chose the args, and whether they include --autocompact */ cliVersion: string | null; passedAutocompact: boolean;
/** the volatile half the conversation holds; null once a compaction may have summarized it away */
volatile: string | null;
sessionId: string | null;
@@ -1350,7 +1350,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
(event) => emit({ ...base(threadId, session.turn?.turnId ?? turnId), ...event })),
mcpConfigPath,
systemPromptPath,
- argsKey, cliVersion: cliHelpVersion,
+ argsKey, cliVersion: cliHelpVersion, passedAutocompact: args.includes("--autocompact"),
volatile: turn.systemVolatile ?? "",
sessionId: sessionId ?? newSessionId,
sawInit: false,
@@ -1715,7 +1715,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
} else if (session.turn && !session.turn.settled) {
const { turnId, input: turn, retryAbort } = session.turn;
// Commander prints this last before exiting; only a launch that passed the flag counts, so the flag-less relaunch can't loop.
- const refusedAutocompact = session.argsKey.includes('"--autocompact"') && /unknown option '--autocompact'/.test(session.stderr);
+ const refusedAutocompact = session.passedAutocompact && /unknown option '--autocompact'/.test(session.stderr);
if (refusedAutocompact) [cliHasAutocompact, autocompactRefusedBy] = [session.cliVersion === cliHelpVersion ? false : cliHasAutocompact, session.cliVersion];
const retry = retryState.get(threadId) ?? { attempt: 0, cancelled: false };
const message = `claude exited ${code} before result${session.stderr ? `: ${session.stderr.trim().slice(-300)}` : ""}`;