feat(workspace): extend read-at-boundary hot-reload to config.model field #126

Closed
opened 2026-05-08 16:10:35 +00:00 by claude-ceo-assistant · 0 comments

Sub-issue of core#117 (workspace config-watcher) — focused remaining gap

Phase 1 investigation of core#117 found that the read-at-boundary pattern (re-read file at each message handler entry) already exists for system-prompt.md via get_system_prompt(config_path) in executor_helpers.py. Mirror that pattern to make config.model hot-reloadable.

With plugin-side hot-reload (core#112) handling SKILL.md content changes and system-prompt already covered, model is the remaining frequently-changed config field that today still requires a container restart.

Proposed approach

  1. Add get_current_model(config_path: str, fallback: str) -> str helper in executor_helpers.py that re-reads config.yaml's model field on each call. Falls back to the parameter if config can't be parsed.
  2. Plumb config_path to MoleculeAIAgentExecutor (constructor field).
  3. In _core_execute, call the helper at the top of the message handler, before agent invocation. If model changed, swap on the agent.
  4. Test (pytest, real-subprocess if reasonable): change model in config.yaml mid-test, send message, assert response carries the new model identifier.

Acceptance criteria

  • Editing config.yaml's model: field while agent is running takes effect at the next message, no container restart.
  • Cold-restart-required fields (runtime, tier, workspace_dir) still trigger restart via existing path — this issue doesn't try to hot-reload those.
  • Test verifies real swap (sonnet → opus or similar).

Out of scope

  • idle_prompt hot-reload (small follow-up; idle loop already polls)
  • category_routing hot-reload (rarely changes; cold-restart fine)
  • Provider switch hot-reload (anthropic ↔ minimax — usually requires re-auth at SDK level; cold-restart safer)
  • watchfiles / background watcher (rejected — read-at-boundary is simpler)

Refs

  • core#117 — parent (closed; existing pattern covers system-prompt)
  • workspace/executor_helpers.py — get_system_prompt is the reference implementation
  • core#112 — plugin-side hot-reload classifier (composes; together they cover most iteration paths)
## Sub-issue of core#117 (workspace config-watcher) — focused remaining gap Phase 1 investigation of core#117 found that the read-at-boundary pattern (re-read file at each message handler entry) already exists for `system-prompt.md` via `get_system_prompt(config_path)` in `executor_helpers.py`. Mirror that pattern to make `config.model` hot-reloadable. With plugin-side hot-reload (core#112) handling SKILL.md content changes and system-prompt already covered, model is the remaining frequently-changed config field that today still requires a container restart. ## Proposed approach 1. Add `get_current_model(config_path: str, fallback: str) -> str` helper in `executor_helpers.py` that re-reads config.yaml's `model` field on each call. Falls back to the parameter if config can't be parsed. 2. Plumb `config_path` to `MoleculeAIAgentExecutor` (constructor field). 3. In `_core_execute`, call the helper at the top of the message handler, before agent invocation. If model changed, swap on the agent. 4. Test (pytest, real-subprocess if reasonable): change model in config.yaml mid-test, send message, assert response carries the new model identifier. ## Acceptance criteria - Editing config.yaml's `model:` field while agent is running takes effect at the **next message**, no container restart. - Cold-restart-required fields (runtime, tier, workspace_dir) still trigger restart via existing path — this issue doesn't try to hot-reload those. - Test verifies real swap (sonnet → opus or similar). ## Out of scope - idle_prompt hot-reload (small follow-up; idle loop already polls) - category_routing hot-reload (rarely changes; cold-restart fine) - Provider switch hot-reload (anthropic ↔ minimax — usually requires re-auth at SDK level; cold-restart safer) - watchfiles / background watcher (rejected — read-at-boundary is simpler) ## Refs - core#117 — parent (closed; existing pattern covers system-prompt) - workspace/executor_helpers.py — `get_system_prompt` is the reference implementation - core#112 — plugin-side hot-reload classifier (composes; together they cover most iteration paths)
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#126
No description provided.