Skip to content

feat(threads): switch providers with conversation history - #1446

Merged
nixuuu merged 2 commits into
feat/provider-switch-workerfrom
feat/provider-switch-history
Nov 28, 2026
Merged

nixuuu merged 2 commits into
feat/provider-switch-workerfrom
feat/provider-switch-history

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 28, 2026

Copy link
Copy Markdown
Member

Admits a provider selection and its message in the same durable operation. After the source journal is durable and the target session is prepared, the new provider receives the visible thread history. The gateway can resume after a quota failure without calling the exhausted model. Each admitted turn retains its execution identity for history, usage and historical operations.

The history reader checks the owner, thread, fork point and rewind visibility on every page. The transfer excludes private reasoning and secret-delivery content. Unfinished actions keep their status. Longer conversations have scoped, searchable pages.

Verified with a real gateway, Postgres and worker using Codex, Claude and Grok through CLIProxyAPI. Both Codex and Grok changed profiles and retrieved the two random facts established earlier in the same conversation. A separate real-CLI test injected HTTP 429 only after a file append. Claude read the existing receipt, the ledger had one entry and the source received zero additional requests. Deterministic integration tests cover retries, reconnect, older workers, preparation failure and queue ordering. The upstream Codex secret-rotation regression also passed. Full verification runs in CI.

Historical operations use the session that ran each turn. Fork, rewind and Undo preserve that provenance. A transfer moves the active session, and a return to a historical provider can recover its context from the transcript. Native goals retain their objective and accumulated usage. The destination receives the remaining budget when its evaluator supports it.

The PostgreSQL 17 upgrade test preserves legacy turns. Targeted tests cover an older worker reconnecting during Undo, historical forks, file-checkpoint compatibility and cleanup of more than one provider profile. Antigravity prompt delivery was verified against its ACP fixture. A live Antigravity binary was unavailable.

A two-home test moved a switched Codex session between different local aliases of the shared profile. Codex resumed on the destination. Claude recovered the original home's decision after a further provider change. Another test verifies a late source usage adjustment while a Codex goal is running on the new account.

@nixuuu
nixuuu added this pull request to stack #1448 November 28, 2026 19:06
@nixuuu
nixuuu marked this pull request as ready for review November 28, 2026 19:27
@nixuuu
nixuuu merged commit b22936a into dev Nov 28, 2026
46 of 48 checks passed
@nixuuu
nixuuu deleted the feat/provider-switch-history branch November 28, 2026 19:28
nixuuu added a commit that referenced this pull request Nov 29, 2026
#1457)

## Change

The rewind admission fixture creates fixed Claude and Codex adapters in
one Effect scope. When rewinding Claude to a new binding, the host
unloads Codex through `useRuntime`. That acquisition previously reached
the real configuration reconciler, which could close the shared scope
while the first post-rewind Claude turn was starting.

Pause acquisition at `useRuntime` so starts, rewinds and cross-provider
unloads all use the fixed fixture runtimes. The test still exercises
both real adapter paths and checks cancellation, redelivery, persisted
receipts, and the next turn on the replacement binding.

## Verification

- Holding Codex cleanup until the third Claude query opened reproduced
the CI failure before the post-rewind turn emitted `turnStarted`. The
same ordering passed three times with this change.
- Ran both provider cases ten times each with `check:tmp`. All 20 passed
and cleaned up.
- Worker typecheck and edited-file lint passed locally.

Related: #1446
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