Skip to content

fix(code): preserve initial prompt across session error transitions#1384

Merged
richardsolomou merged 1 commit intomainfrom
fix/preserve-initial-prompt-on-retry
Mar 31, 2026
Merged

fix(code): preserve initial prompt across session error transitions#1384
richardsolomou merged 1 commit intomainfrom
fix/preserve-initial-prompt-on-retry

Conversation

@richardsolomou
Copy link
Copy Markdown
Member

Problem

When creating a new task with a prompt and the session errors (e.g. "Failed to connect / Internal error"), clicking Retry doesn't re-send the original prompt. The user has to type their prompt again.

This happens because:

  1. createNewLocalSession sends the initial prompt but never stores it on the session object
  2. When the session later transitions to error state (via subscription error, agent crash, or fatal prompt failure), the prompt is lost
  3. setErrorSession carries forward events and logUrl from the existing session but not initialPrompt

Changes

  • Store initialPrompt on the session in createNewLocalSession so it survives error transitions via updateSession
  • Preserve initialPrompt in setErrorSession when carrying forward session state to a new error session
  • Add the initialPrompt field and ContentBlock import to the AgentSession interface in the store

How did you test this?

  • Ran full test suite: 536 tests passing
  • Type check passes

When a new task's initial prompt was sent but the session errored (e.g.
agent crash, subscription error, or fatal prompt failure), the prompt
was lost because it was never stored on the session object. Clicking
Retry would then reconnect without re-sending the original prompt.

Two fixes:
- Store initialPrompt on the session in createNewLocalSession so it
  survives error transitions via updateSession
- Preserve initialPrompt in setErrorSession when carrying forward
  session state to a new error session
@richardsolomou richardsolomou requested a review from a team March 31, 2026 09:57
Copy link
Copy Markdown
Contributor

@joshsny joshsny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@richardsolomou richardsolomou merged commit 0423c18 into main Mar 31, 2026
15 checks passed
@richardsolomou richardsolomou deleted the fix/preserve-initial-prompt-on-retry branch March 31, 2026 10:04
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.

2 participants