You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a CLI backend session (e.g., Claude Code) is resumed with --resume, the system prompt is silently dropped because of this guard:
// Before (broken):if(!params.useResume&¶ms.systemPrompt&¶ms.backend.systemPromptArg){args.push(params.backend.systemPromptArg,params.systemPrompt);}
This means resumed sessions lose access to skills, workspace context, and agent instructions — the model operates "blind" without its configured system prompt.
Session flow WITHOUT this fix:
New session: claude --system-prompt "skills + context" -p "task" ✓ has context
Resumed session: claude --resume <id> -p "follow-up" ✗ no context!
Session flow WITH this fix (systemPromptWhen=always):
New session: claude --system-prompt "skills + context" -p "task" ✓ has context
Resumed session: claude --resume <id> --append-system-prompt "..." -p ✓ has context
Fix
Remove the !params.useResume guard from the system prompt argument builder. When systemPromptWhen is set to "always" in the CLI backend config, the system prompt is now passed on every invocation, including resumed sessions.
Added a test that verifies --append-system-prompt is included in argv when resuming with systemPromptWhen=always, and that the prompt contains <available_skills>.
Why merge
Without this fix, any multi-turn CLI agent session loses its identity after the first turn. The model forgets its skills, workspace layout, and behavioral instructions on resume. This causes degraded responses, inability to use skills, and effectively breaks multi-turn agent workflows for all CLI backends.
This PR fixes a one-line bug in buildCliArgs where the !params.useResume guard incorrectly suppressed system prompt injection on resumed CLI sessions, even when systemPromptWhen: "always" was configured.
Root Cause:
The systemPrompt value passed into buildCliArgs is already pre-filtered by the upstream resolveSystemPromptUsage function, which correctly evaluates the systemPromptWhen setting ("first"/"always"/"never"). The removed guard was redundant—resolveSystemPromptUsage already returns null for resume sessions when systemPromptWhen === "first" (the default), making the additional !params.useResume check in buildCliArgs unnecessary.
Changes:
src/agents/cli-runner/helpers.ts: Removes !params.useResume && from the system prompt condition (line 362). The model-arg and session-ID guards remain correctly gated on !params.useResume to preserve existing behavior.
src/agents/cli-runner.test.ts: Adds integration test verifying that a resumed claude-cli session with systemPromptWhen: "always" produces --append-system-prompt in the spawned argv with correct system prompt content.
Safety:
No regressions expected. The default systemPromptWhen: "first" behavior is unaffected because resolveSystemPromptUsage already filters it out for non-new sessions. Users without a custom systemPromptWhen config are unaffected. The fix is narrowly scoped and backed by comprehensive test coverage.
Confidence Score: 5/5
This PR is safe to merge. It is a minimal, targeted one-line fix with no regression risk for default configurations.
The fix is a single-line removal of a redundant guard. Data flow verification confirms correctness: buildCliArgs receives a systemPrompt value already pre-filtered by resolveSystemPromptUsage, which correctly handles the first/always/never policy. No existing tests break, and the new test exercises the full path end-to-end including skill discovery and system prompt generation. The change correctly handles both the default case (systemPromptWhen: "first" on resume returns null upstream) and the bug case (systemPromptWhen: "always" on resume now includes the prompt). Model and session ID guards remain properly constrained with !params.useResume.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a CLI backend session (e.g., Claude Code) is resumed with
--resume, the system prompt is silently dropped because of this guard:This means resumed sessions lose access to skills, workspace context, and agent instructions — the model operates "blind" without its configured system prompt.
Fix
Remove the
!params.useResumeguard from the system prompt argument builder. WhensystemPromptWhenis set to"always"in the CLI backend config, the system prompt is now passed on every invocation, including resumed sessions.Added a test that verifies
--append-system-promptis included in argv when resuming withsystemPromptWhen=always, and that the prompt contains<available_skills>.Why merge
Without this fix, any multi-turn CLI agent session loses its identity after the first turn. The model forgets its skills, workspace layout, and behavioral instructions on resume. This causes degraded responses, inability to use skills, and effectively breaks multi-turn agent workflows for all CLI backends.