Skip to content

fix(agent): preserve pre-written claude-user-request.txt in agent mode#1440

Open
syf2211 wants to merge 1 commit into
anthropics:mainfrom
syf2211:fix/1427-scope-prompt-wipe
Open

fix(agent): preserve pre-written claude-user-request.txt in agent mode#1440
syf2211 wants to merge 1 commit into
anthropics:mainfrom
syf2211:fix/1427-scope-prompt-wipe

Conversation

@syf2211

@syf2211 syf2211 commented Jun 27, 2026

Copy link
Copy Markdown

Summary

Agent mode no longer wipes the entire claude-prompts directory. It only removes claude-prompt.txt, the file agent mode owns and rewrites.

Motivation

Fixes #1427. Composite workflows can pre-write claude-user-request.txt in an earlier step so the SDK takes the multi-block path and processes slash commands. PR #1288 added an unconditional rm -rf on the prompt directory, which deleted that pre-written file before the SDK ran.

Changes

  • prepareAgentMode: replace directory rm -rf with targeted removal of claude-prompt.txt only
  • Add regression test ensuring a pre-written claude-user-request.txt survives agent prepare

Tests

  • bun test test/modes/agent.test.ts — 7/7 passed
  • bun run typecheck — passed
  • bun run format:check — passed
  • composer-2.5 review: APPROVE

Notes

Tag mode still performs full directory cleanup in create-prompt (it writes both files). Agent mode intentionally preserves claude-user-request.txt for composite workflows. On non-ephemeral self-hosted runners without a pre-write step, a stale user-request file could theoretically persist if RUNNER_TEMP is not cleared between jobs — same class of concern noted in #1287, traded off here to unblock composite slash-command workflows.

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
@tarunag10

Copy link
Copy Markdown
Contributor

This looks like the lowest-blast-radius fix for #1427 to me.

I had explored an alternate first-class user_request input in #1434, but this PR better preserves the existing composite-action behavior that regressed in v1.0.146: pre-writing claude-user-request.txt before invoking agent mode.

The main validation I would want is exactly what this tests: agent mode rewrites its owned claude-prompt.txt while leaving a pre-written claude-user-request.txt intact, so the SDK still takes the multi-block path for slash-command processing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent mode wipe of claude-prompts/ (PR #1288) breaks composite actions that pre-write claude-user-request.txt

2 participants