Skip to content

fix(session): recover stale encrypted reasoning - #48918

Open
1837620622 wants to merge 1 commit into
anomalyco:devfrom
1837620622:fix/stale-encrypted-reasoning
Open

1837620622 wants to merge 1 commit into
anomalyco:devfrom
1837620622:fix/stale-encrypted-reasoning

Conversation

@1837620622

Copy link
Copy Markdown

Issue for this PR

Fixes #48915

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Resuming a Muse Spark / OpenAI Responses session after idle fails with:

reasoning `encrypted_content` was not issued to this caller

OpenCode stored that caller-bound blob and treated HTTP 400 as fatal, so the session stayed bricked.

This follows the existing context-overflow recovery path:

  1. Classify those errors as stale-reasoning
  2. If no assistant output has started, drop reasoningEncryptedContent / itemId from stored reasoning
  3. Retry the turn once

Readable reasoning text stays. Live tool-loop encrypted state is left alone unless the provider rejects it.

Related: #48741, #48805

How did you verify your code works?

  • packages/llm: bun test test/provider-error.test.ts
  • packages/opencode: bun test test/provider/error.test.ts and the fromError case in test/session/message-v2.test.ts
  • packages/core: bun test test/session-runner.test.ts (90 pass), including three new recovery tests plus existing overflow and encrypted-reasoning tests

Screenshots / recordings

n/a (non-UI)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Retry once after stripping caller-bound reasoning.encrypted_content when the provider rejects it, matching overflow recovery.
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

PR #48908 - fix(session): recover from stale encrypted reasoning on provider rejection

Why it might be related:
This PR addresses the same issue with stale encrypted reasoning recovery. Both PRs appear to handle the recovery path when encrypted reasoning content becomes stale during session resumption. They likely overlap in implementation or address the same bug from different angles.

Note: PR #43595 fix(opencode): recover stale encrypted reasoning state is an older related PR on this topic, but may be superseded.

@1837620622

Copy link
Copy Markdown
Author

This bricks Muse Spark 1.3 on 1.18.30 when resuming an old session. Tests in packages/core session-runner pass. Please review/merge when you can.

@SynacNipo

Copy link
Copy Markdown

hopefully

@kungfooman

Copy link
Copy Markdown

I got that error message too now, what helps is using /models to e.g. switch from 1.2 to 1.3 or vice versa. So it's not a "full" brick.

@yakovexplorer

Copy link
Copy Markdown

still persists on 1.18.31. I hope this gets merged soon.

@kvnloo

kvnloo commented Sep 15, 2026

Copy link
Copy Markdown

Why this matters

Resuming after idle still bricks sessions with stale encrypted_content / invalid_encrypted_content on 1.18.31 (see thread + #48915). Two open PRs both try to recover — maintainers need one shape on dev, not a third.

Evidence

Two open recoveries for stale encrypted reasoning (encrypted_content not issued to this caller / invalid_encrypted_content):

#48918 #48908
Base dev v2 (currently conflicting)
Tip 87dd316 73e8e76
Error class packages/llm + opencode provider error packages/ai
Durability strip + retry (also touches message-v2 / processor) strip + SessionEvent.MessageContentUpdated so projection replay keeps sanitized state

Community still sees the brick on 1.18.31 (thread on #48918).

Architecture (proposal)

Maintainer call: which shape should land on dev? Happy to help rebase/tests on the chosen one — not opening a third PR.

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.

Muse Spark 1.3: resuming a session after idle fails with reasoning encrypted_content not issued to this caller

5 participants