Skip to content

fix(gastown): push new model onto resumed mayor session on hot-swap#2999

Merged
kilo-code-bot[bot] merged 1 commit intogastown-stagingfrom
gt/toast/1e6daf57
May 1, 2026
Merged

fix(gastown): push new model onto resumed mayor session on hot-swap#2999
kilo-code-bot[bot] merged 1 commit intogastown-stagingfrom
gt/toast/1e6daf57

Conversation

@jrf0110
Copy link
Copy Markdown
Contributor

@jrf0110 jrf0110 commented May 1, 2026

Summary

Fixes a regression where changing the mayor's model in Gastown town settings did not take effect on the running mayor until the user manually ran /model in chat.

Commit 9785570b9 (skip initial prompt on resume) dropped the entire client.session.prompt(...) call when resuming an existing session to avoid duplicating MAYOR_STARTUP_PROMPT. That call was also carrying the model param, so the SDK server never learned about the new per-session model selection and the resumed session kept running on the old model.

This change extracts the fresh-vs-resumed session-prompt logic into a new applyModelToSession helper in services/gastown/container/src/process-manager.ts:

  • Fresh session (unchanged behavior): sends MAYOR_STARTUP_PROMPT with the model param so the first turn uses the new model.
  • Resumed session (the fix): sends a noReply: true prompt carrying only the model param and an empty text part. The SDK treats this as a session-state update (no model invocation), and the next real user turn uses the updated model. Errors on this path are caught and logged — the SDK server already loaded the new model from the refreshed KILO_CONFIG_CONTENT at startup, so a push failure is not fatal.

Verification

  • pnpm --filter gastown-container test — the 4 new applyModelToSession tests pass (fresh-path sends startup prompt + model, resumed-path sends empty + noReply: true + model, resumed-path error is swallowed, resumed-path success is logged). Two pre-existing JWT-header failures in plugin/client.test.ts are unrelated to this change.
  • Inspected the resumed-session path to confirm no duplicate MAYOR_STARTUP_PROMPT turn is injected (regression from 9785570 not reintroduced).
  • SDK server rollback on updateAgentModel failure is preserved (control flow around applyModelToSession is unchanged).

Visual Changes

N/A

Reviewer Notes

  • The resumed-session path uses parts: [{ type: 'text', text: '' }] plus noReply: true. If the SDK ever rejects empty text parts in a future version, swap to ' '. The issue thread mentions client.session.command as a fallback, but that would require the /model command to be registered server-side which is brittle.
  • applyModelToSession is exported so tests can exercise both paths with a minimal fake client (structural SessionPromptClient type defined locally — no mocking of the whole KiloClient).
  • Full pnpm typecheck was skipped per AGENTS.md (too heavy); package-level typecheck is covered by vitest compile.

When a user changes the mayor's model in town settings, updateAgentModel
restarts the SDK server with new KILO_CONFIG_CONTENT and resumes the
existing session from kilo.db. Commit 9785570 intentionally stopped
sending any session.prompt on resume to avoid duplicating the
MAYOR_STARTUP_PROMPT, but that also dropped the model param — so the
resumed session kept its prior per-session model until the user ran
/model manually.

Extract the fresh vs. resumed session-prompt logic into applyModelToSession
and on resume send a noReply:true prompt carrying only the new model
param. This updates the SDK server's per-session model without replaying
the startup prompt. Errors on the resume path are swallowed so the
hot-swap still succeeds; the SDK server fell back to the config-loaded
model at startup, which was already updated.

Add container tests covering both fresh and resumed paths.
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 1, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • services/gastown/container/src/process-manager.test.ts
  • services/gastown/container/src/process-manager.ts
  • services/gastown/container/vitest.config.ts

Reviewed by gpt-5.5-2026-04-23 · 674,099 tokens

@kilo-code-bot kilo-code-bot Bot merged commit c532f40 into gastown-staging May 1, 2026
2 checks passed
@kilo-code-bot kilo-code-bot Bot deleted the gt/toast/1e6daf57 branch May 1, 2026 16:22
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