Skip to content

fix(chat): let a model pick right after a Thinking change go through - #1796

Merged
uzairansaruzi merged 1 commit into
masterfrom
issue/1795-reasoning-generation
Nov 23, 2026
Merged

uzairansaruzi merged 1 commit into
masterfrom
issue/1795-reasoning-generation

Conversation

@uzairansaruzi

@uzairansaruzi uzairansaruzi commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Linked issue

Fixes #1795

What changed

A tester on 2.2 (1) changed Thinking on a new Hermes chat, then picked a model, and got "This chat changed on the server. Reopen it and try again." Picking the model first worked.

The host saves a Thinking change as a fenced policy edit that moves the session's revision and execution generation. It announces both in the payload of a session.updated event (hermes-agent 3b42157, gateway/session_mutations.py _project_result, hermes_state_runtime.py receipt). Hermex took the revision from that payload, but took the generation only from the event envelope, which is empty on an idle chat. So the next model change sent a stale expected_generation, and the host refused it with stale_generation. Hermex now also takes payload.execution_generation from session.updated, through the existing forward-only adoptGeneration.

How it was tested

Proof: the new HermesChatSettingsTests case failed before the fix (the first model pick after a Thinking change sent generation 1 instead of 2) and passes after it.

  • scripts/test-sim <iPhone 17e> --only HermesMobileTests/HermesChatSettingsTests: 52 passed
  • --only HermesConversationTests HermesChatTurnTests HermesHistoryRewindTests HermesSessionActionsTests: 161 passed
  • Signed Debug build installed and launched with build_run_sim. No live repro: the only route to a fresh chat on the test host went through real bot sessions.

Checklist

  • Local validation passes using scripts/test-sim <assigned-simulator-udid> with the tests required by AGENTS.md § Verifying; the selection and results are recorded above
  • New/changed Codable models decode tolerantly (optionals for fields the server might add or rename)
  • No new third-party dependencies (the list in AGENTS.md is locked)
  • No invented API endpoints or JSON shapes (verified against upstream source or a running server)

Reviewed with sol-loop: 1 round with gpt-6.2-sol on high. Sol verdict: approved

Created with Claude Opus 5.5 in Claude Code (T3 Code); investigation partner GPT-6.2 Astra, reviewer GPT-6.2 Sol.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Model changes made after adjusting reasoning settings now use the latest session state, helping ensure updates are applied against the correct version.
    • Improved handling of session updates so subsequent model changes retain the state information announced by the session.

A session.updated receipt carries the new execution_generation in its
payload; the conversation read it only from the envelope, so the next
model pick sent a stale fence and the host refused it.

Fixes #1795

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

HermesConversation now adopts execution_generation from session.updated payloads. A test verifies that the next model mutation sends the revision and generation announced by the host.

Changes: Session generation fences

Layer / File(s) Summary
Adopt and verify session fences
HermesMobile/Features/Hermes/HermesConversation.swift, HermesMobileTests/HermesChatSettingsTests.swift
adoptFrameFences adopts execution_generation from session.updated payloads. The test checks that the next model mutation includes the host-announced revision and generation as expected fences.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • uzairansaruzi/hermex#1775: Changes deferred model-pick behavior in the session.updated frame path and extends HermesChatSettingsTests.

Suggested reviewers: audichuang

Merge Risk: Minimal · up to c8409

Changing Thinking and then picking a model in a new chat should now send the correct generation instead of hitting the stale-chat error. The change is small and has a regression test, so no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: a model pick right after a Thinking change no longer fails with the stale-chat error. The raw summary shows the change adopts payload.execution_generation from session…
Linked Issues check Passed Issue #1795 requires that adopting the Hermes session.updated payload fence keeps the client generation current, so a model pick after a Thinking change does not send a stale expected_generation. The …
Out of Scope Changes check Passed The whole-PR change set, as summarized, has two parts. The first is a one-line change in HermesMobile/Features/Hermes/HermesConversation.swift that adopts execution_generation from the session.updated…
Full details: Title check

Explanation

The title names the main change: a model pick right after a Thinking change no longer fails with the stale-chat error. The raw summary shows the change adopts payload.execution_generation from session.updated events, which fixes that path. The title is specific and matches the linked objectives.

Full details: Linked Issues check

Explanation

Issue #1795 requires that adopting the Hermes session.updated payload fence keeps the client generation current, so a model pick after a Thinking change does not send a stale expected_generation. The PR adds payload execution_generation adoption in HermesConversation.adoptFrameFences, through the existing forward-only adoptGeneration (the summary describes the change as a one-line addition, and top-level execution_generation handling for other events is unchanged). The new HermesChatSettingsTests case covers the path: a session.updated event with revision 3 and execution generation 2 is followed by a model mutation that sends both values as fences. The PR description reports that this test failed before the fix and passes after it. Evidence limit: the repository diff call failed because changed blobs were missing from the checkout, and the file read was truncated before adoptFrameFences. The verdict relies on the supplied raw summary and PR description, not a direct read of the changed lines. The issue has no non-coding requirements that affect this verdict.

Full details: Out of Scope Changes check

Explanation

The whole-PR change set, as summarized, has two parts. The first is a one-line change in HermesMobile/Features/Hermes/HermesConversation.swift that adopts execution_generation from the session.updated payload. The second is a new test case in HermesMobileTests/HermesChatSettingsTests.swift that verifies this path. Both connect directly to issue #1795. No unrelated files or API changes appear in the supplied summary (declaration changes: none). The direct diff could not be read, so this verdict rests on the supplied summary and its line counts (+1 and +13).

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a9861b9 and c840981.

Files selected for processing: 2

  • HermesMobile/Features/Hermes/HermesConversation.swift
  • HermesMobileTests/HermesChatSettingsTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Updates HermesConversation to read payload.execution_generation from session.updated.

  • A model pick after a Thinking change uses the updated chat generation.

Reviews (1) · Last reviewed commit: "fix(chat): keep the host's generation af..." · Reviewed by Greptile

@uzairansaruzi
uzairansaruzi merged commit f24d333 into master Nov 23, 2026
6 checks passed
@uzairansaruzi
uzairansaruzi deleted the issue/1795-reasoning-generation branch November 23, 2026 22:02
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.

fix(chat): a model pick right after a Thinking change fails as a stale chat

1 participant