[BUG] Running agent stops when navigating back to a previous message

Open
#110,625 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
ai, cli

Research direction

Start by tracing how conversation navigation and editing handle active agent runs, then follow the cancellation path when a previous message is retried. The report names no files or tests, so first locate the relevant terminal UI and agent lifecycle code and inspect existing coverage. Done means reproducing the steps no longer cancels an unrelated running agent, while explicit cancellation still works.

Written by the indexing model from the issue text.

Description

area:agents area:tui bug platform:macos
Preflight Checklist
  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code
What's Wrong?

Bug Description

When I start an agent and it is still running, then navigate back to a previous message in the conversation to edit or retry a prompt, the running agent is automatically canceled.

The agent's task is completely unrelated to the message I'm editing.

Steps to Reproduce:

  1. Start an agent with a task.
  2. While the agent is running, send another prompt.
  3. Navigate back to an earlier message and edit or retry it.
  4. The running agent gets canceled unexpectedly.

Expected Behavior:
The running agent should continue executing independently unless I explicitly cancel it or modify the task it is working on.

Actual Behavior:
The agent stops automatically when I navigate back and edit an unrelated message.

Impact:
This interrupts development workflows, wastes time and tokens, and forces me to restart tasks unnecessarily.

What Should Happen?

The running agent should continue working independently, even when I navigate back to an earlier message, edit it, or retry a different prompt.

Editing or retrying an unrelated message should not automatically cancel any active agents.

Agents should only stop when I explicitly cancel them or when their own task is affected.

Error Messages/Logs

Steps to Reproduce
  1. Open Claude Code and start an agent with a task that takes some time to complete.
  2. While the agent is still running, send a new prompt in the conversation.
  3. Navigate back to an earlier message in the conversation.
  4. Edit or retry that previous message.
  5. Observe that the running agent is automatically canceled, even though its task is completely unrelated to the edited message.

Expected: The agent should continue running independently.

Actual: The agent is unexpectedly canceled without explicitly requesting cancellation.

Note: This issue interrupts ongoing development tasks and causes unnecessary token consumption when tasks need to be restarted.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.287 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

Dominant language
TypeScript
Stars
156k
Forks
25k
Avg merge
16h 19m
Merged PRs (30d)
5

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from anthropics/claude-code

All issues in anthropics/claude-code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.