Skip to content

fix(wework): restore Codex failed turns after task reload - #2206

Merged
qdaxb merged 1 commit into
mainfrom
fix/codex-failed-turn-restoration
Jul 24, 2026
Merged

qdaxb merged 1 commit into
mainfrom
fix/codex-failed-turn-restoration

Conversation

@qdaxb

@qdaxb qdaxb commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • recognize Codex failed turns and preserve their error metadata in normalized runtime messages
  • persist a stable failed assistant message when Codex does not include one in the thread transcript
  • merge the cached failed message when reloading failed tasks without duplicating provider messages
  • restore error details in the Wework transcript and keep the retry action available
  • add unit coverage and a real desktop E2E regression for fail, switch away, reload, expand error, and retry
  • document the failed-turn persistence behavior in Chinese and English architecture docs

Root cause

Codex can emit a failed terminal event without persisting an assistant item in thread/read. Wework rebuilds a task transcript from that provider response after switching away or reopening the task, so the failed assistant card disappeared even though the original run had shown the error.

Impact

Failed Codex turns now remain visible after task navigation or reload. Users can inspect the original Codex error and retry from the restored failure card.

Validation

  • WEWORK_E2E_SCREENSHOTS=final node wework/e2e/desktop/task-flow.e2e.mjs --retry-only
  • cargo test --lib runtime_work::handler::tests (34 passed)
  • cargo test --lib runtime_work::transcript::tests (29 passed)
  • pnpm --dir wework test --run src/features/workbench/runtimePaneMessages.test.ts src/components/layout/runtimeTranscriptMessages.test.ts (36 passed)
  • pre-push: Wework ESLint, TypeScript, and unit tests
  • pre-push: Executor format, cargo test --all-features --lib, and Clippy

Summary by CodeRabbit

  • Bug Fixes

    • Failed assistant responses now retain their error details, even when the provider transcript omits them.
    • Restored tasks display failure cards and retry controls after reopening or switching back.
    • Duplicate failure messages are prevented during transcript restoration.
    • Failed responses with partial output preserve the available content alongside the error.
  • Tests

    • Added coverage for failure persistence, transcript restoration, error display, and retry behavior.

@qdaxb
qdaxb marked this pull request as ready for review July 24, 2026 15:12
@qdaxb
qdaxb merged commit 02aea86 into main Jul 24, 2026
19 of 22 checks passed
@qdaxb
qdaxb deleted the fix/codex-failed-turn-restoration branch July 24, 2026 15:12
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 566aa63a-0231-48b4-bfa6-fe3316356d6f

📥 Commits

Reviewing files that changed from the base of the PR and between bd397bc and 394d60b.

📒 Files selected for processing (11)
  • docs/en/wegent/developer-guide/architecture.md
  • docs/zh/wegent/developer-guide/architecture.md
  • executor/src/runtime_work/handler/helpers/transcript.rs
  • executor/src/runtime_work/handler/queries.rs
  • executor/src/runtime_work/handler/tests.rs
  • executor/src/runtime_work/handler/turns.rs
  • executor/src/runtime_work/transcript.rs
  • wework/e2e/desktop/task-flow.e2e.mjs
  • wework/src/features/workbench/runtimePaneMessages.test.ts
  • wework/src/features/workbench/runtimePaneMessages.ts
  • wework/src/types/api.ts

📝 Walkthrough

Walkthrough

Codex failures now persist as structured local assistant messages, merge into missing transcript entries without duplication, propagate error metadata through Wework, and restore error cards and retry actions after task switching or reopening.

Changes

Codex failure persistence and restoration

Layer / File(s) Summary
Persist failed Codex turns
executor/src/runtime_work/transcript.rs, executor/src/runtime_work/handler/turns.rs, executor/src/runtime_work/handler/tests.rs
Failed turns emit assistant messages with failure status and error text; handler failures persist structured messages in the runtime handle.
Merge missing cached failures
executor/src/runtime_work/handler/helpers/transcript.rs, executor/src/runtime_work/handler/queries.rs, executor/src/runtime_work/handler/tests.rs
Failed local-task messages are appended only when their IDs are absent from the provider transcript.
Map failure metadata to Wework
wework/src/types/api.ts, wework/src/features/workbench/runtimePaneMessages.ts, wework/src/features/workbench/runtimePaneMessages.test.ts
Runtime error and error-type fields are mapped into workbench messages and covered by tests.
Validate retry restoration flow
wework/e2e/desktop/task-flow.e2e.mjs, docs/en/wegent/developer-guide/architecture.md, docs/zh/wegent/developer-guide/architecture.md
End-to-end coverage verifies restored error cards, error details, retry success, and retry-only execution; architecture documentation describes the persistence and merge behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Codex
  participant Executor
  participant RuntimeHandle
  participant Wework
  participant User
  Codex->>Executor: return failed turn
  Executor->>RuntimeHandle: persist failed assistant message
  Wework->>Executor: read task transcript
  Executor->>RuntimeHandle: merge missing failure by message ID
  Executor-->>Wework: return failed message and error metadata
  Wework-->>User: render error card and retry action
  User->>Wework: click retry
  Wework->>Codex: submit retry turn
Loading

Possibly related PRs

Suggested reviewers: micro66

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/codex-failed-turn-restoration

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant