Skip to content

fix(glm): stabilize reasoning and context reporting#3615

Merged
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/fix-resume-unsupported-config
Jul 21, 2026
Merged

fix(glm): stabilize reasoning and context reporting#3615
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/fix-resume-unsupported-config

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Why: GLM 5.2 sessions could restore unsupported reasoning settings, use a stale 128K context window, and replace trustworthy context usage with incomplete stream or compaction readings. This made the context meter jump between full and empty.

Changes

  • Restore only persisted config options that the resumed agent still advertises.
  • Define GLM 5.2 reasoning as high and max only across session controls and cloud-run request validation.
  • Normalize GLM 5.2 to its 1M context window even when the gateway reports stale metadata.
  • Keep context usage monotonic through incomplete stream snapshots and retain the previous reading when compaction usage is unavailable.

@trunk-io

trunk-io Bot commented Jul 21, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 72f2e42.

@tatoalo tatoalo self-assigned this Jul 21, 2026
@tatoalo tatoalo added the Stamphog This will request an autostamp by stamphog on small changes label Jul 21, 2026
@tatoalo
tatoalo marked this pull request as ready for review July 21, 2026 11:33
github-actions[bot]
github-actions Bot previously approved these changes Jul 21, 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.

Clean defensive fix: filters persisted config options to only those the resumed session actually supports, preventing errors when restoring settings an agent no longer exposes. Test covers the new filtering behavior precisely.

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

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

---

### Issue 1 of 2
packages/core/src/sessions/sessionService.ts:2043-2045
**Stale Values Pass ID Filter**

When a live select option keeps the same `id` but removes or renames the persisted value, this filter still restores that stale value. The failed mutation is only logged after the stale value has already been merged into local and persisted state, so the connected UI can show a setting the resumed agent did not accept.

### Issue 2 of 2
packages/core/src/sessions/sessionService.ts:2047
**Missing Capabilities Restore Everything**

When reconnect omits `configOptions`, such as after session compaction, this fallback restores every persisted option without checking whether the resumed agent still supports it. A stale reasoning-effort option can therefore reach `setConfigOption` and reproduce the reconnect failure this change is intended to prevent.

Reviews (1): Last reviewed commit: "fix(sessions): skip unsupported settings..." | Re-trigger Greptile

Comment thread packages/core/src/sessions/sessionService.ts Outdated
Comment thread packages/core/src/sessions/sessionService.ts Outdated
@github-actions
github-actions Bot dismissed their stale review July 21, 2026 11:36

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

@tatoalo tatoalo changed the title fix(sessions): skip unsupported settings on resume fix(sessions): restore valid reasoning settings Jul 21, 2026

@stamphog stamphog 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.

The fix correctly filters restored options by ID match when live options are available, but the greptile bot raised valid P1 concerns — still present in the current diff — that the fix is incomplete: the compaction fallback (liveConfigOptions undefined) restores every persisted option unfiltered, which is the exact path where the original reconnect failure can reproduce. These bot concerns were not addressed between the flagged commit and the current head.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 21, 2026
@tatoalo tatoalo changed the title fix(sessions): restore valid reasoning settings fix(glm): stabilize reasoning and context reporting Jul 21, 2026
Restore only the persisted config options a resumed session still
advertises and still offers a value for; when the agent reports no
options (e.g. after compaction) restore nothing rather than push a
value it may reject. Define GLM 5.2 reasoning as high/max across
session controls and cloud-run validation, normalize its 1M context
window when the gateway reports stale metadata, and keep context usage
monotonic across incomplete stream and compaction snapshots.
@tatoalo
tatoalo force-pushed the posthog-code/fix-resume-unsupported-config branch from d46882d to 72f2e42 Compare July 21, 2026 12:25
@tatoalo tatoalo added the Stamphog This will request an autostamp by stamphog on small changes label Jul 21, 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. The two P1 bot concerns (stale-value ID filter, compaction fallback restoring everything unvalidated) are both addressed in the current diff — isPersistedOptionSupported validates value availability, and the compaction path conservatively restores nothing. The stamphog bot reviewed an older commit; the current head resolves both issues with test coverage.

@trunk-io
trunk-io Bot merged commit 2f3bc90 into main Jul 21, 2026
37 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/fix-resume-unsupported-config branch July 21, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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