fix(agent): preserve pre-written claude-user-request.txt in agent mode#1440
Open
syf2211 wants to merge 1 commit into
Open
fix(agent): preserve pre-written claude-user-request.txt in agent mode#1440syf2211 wants to merge 1 commit into
syf2211 wants to merge 1 commit into
Conversation
Agent mode previously wiped the entire claude-prompts directory, deleting claude-user-request.txt that composite workflows may write before invoking the action. Only remove claude-prompt.txt, which agent mode owns. Fixes anthropics#1427
Contributor
|
This looks like the lowest-blast-radius fix for #1427 to me. I had explored an alternate first-class The main validation I would want is exactly what this tests: agent mode rewrites its owned |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Agent mode no longer wipes the entire
claude-promptsdirectory. It only removesclaude-prompt.txt, the file agent mode owns and rewrites.Motivation
Fixes #1427. Composite workflows can pre-write
claude-user-request.txtin an earlier step so the SDK takes the multi-block path and processes slash commands. PR #1288 added an unconditionalrm -rfon the prompt directory, which deleted that pre-written file before the SDK ran.Changes
prepareAgentMode: replace directoryrm -rfwith targeted removal ofclaude-prompt.txtonlyclaude-user-request.txtsurvives agent prepareTests
bun test test/modes/agent.test.ts— 7/7 passedbun run typecheck— passedbun run format:check— passedNotes
Tag mode still performs full directory cleanup in
create-prompt(it writes both files). Agent mode intentionally preservesclaude-user-request.txtfor composite workflows. On non-ephemeral self-hosted runners without a pre-write step, a stale user-request file could theoretically persist ifRUNNER_TEMPis not cleared between jobs — same class of concern noted in #1287, traded off here to unblock composite slash-command workflows.