Skip to content

fix(models): Persist selected model into new sessions#2690

Merged
charlesvien merged 4 commits into
mainfrom
fix/persist-selected-model-on-new-task
Jun 16, 2026
Merged

fix(models): Persist selected model into new sessions#2690
charlesvien merged 4 commits into
mainfrom
fix/persist-selected-model-on-new-task

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Problem

The model picked on the task input page could be dropped when starting a new task, so the session silently ran Opus 4.8 instead of the selected model (for example gpt-5.5). The input page restored the saved model before the settings store finished its async hydration, so it read empty and fell back to the server default. Separately, the adapter and the model were resolved from different sources and sent independently, so a Codex model could pair with the Claude adapter, which then silently rewrote the model to Opus.

Changes

  1. Gate preview model resolution on settings hydration and re-derive once it lands (usePreviewConfig)
  2. Clear stale config options on adapter change so a previous adapter's model id cannot leak through
  3. Block task submit while the preview config is still loading (TaskInput)
  4. Log instead of silently falling back when a non-Anthropic model reaches the Claude adapter (base-acp-agent)
  5. Add a regression test for a Codex model id on the Claude adapter

How did you test this?

  • pnpm --filter @posthog/agent typecheck (clean)
  • pnpm --filter @posthog/agent exec vitest run claude-agent.resume-model.test.ts (6/6 pass, including the new case)
  • pnpm exec biome lint on the four changed files (clean)
  • Not run: full pnpm typecheck fails on pre-existing @posthog/ui and @posthog/web errors in canvas/ and @posthog/quill/quill-charts, none in the files this PR touches

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 6452849.

@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/agent/src/adapters/claude/claude-agent.resume-model.test.ts:173-190
**Standalone `it` where a parameterised block fits**

The team prefers parameterised tests. There are now two standalone `it` calls covering `newSession` (line 156 and here). The new case exercises a different model value and an extra assertion (`warnSpy`), but both cases could live in a single `it.each` table: one column for `model`, one for `expectedCurrentValue`, and an optional `expectsWarn` flag — or split into two `it.each` blocks grouped by concern. As written, a third scenario would again be a standalone `it`, making the pattern diverge further from the rest of the file.

Reviews (1): Last reviewed commit: "persist selected model into new sessions" | Re-trigger Greptile

Comment thread packages/agent/src/adapters/claude/claude-agent.resume-model.test.ts Outdated
@charlesvien charlesvien added Stamphog This will request an autostamp by stamphog on small changes Create Release This will trigger a new release labels Jun 16, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No showstoppers. Targeted bug fixes for model persistence (hydration race), codex MCP crashes (sub-table collapsing, bare-key guard, reachability probe), and adapter/model desync logging. All new paths are tested, boundary rules respected, and the resolved bot comment was already addressed in this diff.

@charlesvien charlesvien merged commit df5d67c into main Jun 16, 2026
29 checks passed
@charlesvien charlesvien deleted the fix/persist-selected-model-on-new-task branch June 16, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create Release This will trigger a new release Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant