fix: skip --append-system-prompt-file on resumed claude sessions

On resumed sessions the agent instructions are already present in the
session cache. Unconditionally passing --append-system-prompt-file
re-injects 5-10K redundant tokens per heartbeat and may be rejected by
the Claude CLI when combined with --resume.

Guard the flag behind `!resumeSessionId` so it is only appended on
fresh session starts.

Fixes: #2848
This commit is contained in:
lempkey 2026-04-06 16:11:39 +01:00 committed by dotta
parent 667d5a7384
commit 3cfbc350a0
2 changed files with 95 additions and 1 deletions

View file

@ -448,7 +448,10 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
}
if (effort) args.push("--effort", effort);
if (maxTurns > 0) args.push("--max-turns", String(maxTurns));
if (effectiveInstructionsFilePath) {
// On resumed sessions the instructions are already in the session cache;
// re-injecting them via --append-system-prompt-file wastes 5-10K tokens
// per heartbeat and the Claude CLI may reject the combination outright.
if (effectiveInstructionsFilePath && !resumeSessionId) {
args.push("--append-system-prompt-file", effectiveInstructionsFilePath);
}
args.push("--add-dir", skillsDir);