Skip to content

Conversation

@Ridwannurudeen
Copy link
Contributor

Summary

Implements selective hot-reload for runtime configs as requested in #984. Instead of restarting all orchestrators on every config file change, the system now:

  • Reads the raw JSON5 from disk and compares field-by-field against the previous snapshot
  • Safe fields (system_prompt_base, system_governance, system_prompt_examples, hertz) are updated in-place on the live RuntimeConfig via setattr() — no orchestrator restart needed
  • Structural fields (agent_inputs, agent_actions, cortex_llm, simulators, backgrounds, etc.) still trigger the existing full reload path
  • File touched but unchanged — detected and skipped entirely (no reload at all)

Key design decisions

Decision Rationale
Raw JSON5 deep comparison Avoids model serialization issues; catches nested changes reliably
hertz validation (must be > 0) Prevents division-by-zero in the cortex loop
No new dependencies Uses existing json5 import already in both cortex files
No new files All logic lives in CortexRuntime and ModeCortexRuntime where _check_config_changes already exists
Both runtimes covered Single-mode and multi-mode get the same selective reload

Multi-mode specifics

  • Top-level safe fields: system_governance, system_prompt_examples
  • Per-mode safe fields: system_prompt_base, system_prompt_examples, hertz, description, display_name
  • Mode added/removed → full reload
  • Transition rules changed → full reload
  • Changes to inactive modes update ModeConfig only; changes to the active mode also patch the live RuntimeConfig

Files changed

  • src/runtime/single_mode/cortex.py — added _read_raw_config, _detect_changed_fields, _apply_safe_reload; renamed _reload_config_full_reload; updated _check_config_changes routing logic
  • src/runtime/multi_mode/cortex.py — same pattern adapted for ModeSystemConfig + ModeConfig hierarchy
  • tests/runtime/single_mode/test_cortex.py — updated existing tests + 11 new selective reload tests
  • tests/runtime/multi_mode/test_cortex.py — updated existing tests + 12 new selective reload tests

Test plan

  • All 62 runtime cortex tests pass (21 new + 41 existing updated)
  • Full suite: 1995 passed (2 pre-existing failures unrelated to this PR)
  • Safe-only field changes verified to skip _full_reload
  • Unsafe field changes verified to trigger _full_reload
  • File-touch-without-content-change verified to skip all reload
  • Invalid hertz values (0, negative) rejected with warning
  • Per-mode changes on active vs inactive modes handled correctly

Closes #984

Replace the full-restart reload with a selective approach that detects
which config fields actually changed via raw JSON5 comparison.

Safe fields (system_prompt_base, system_governance, system_prompt_examples,
hertz) are updated in-place on the live RuntimeConfig without stopping
orchestrators. Structural fields (agent_inputs, agent_actions, cortex_llm,
simulators, backgrounds) still trigger a full reload.

Covers both single-mode CortexRuntime and multi-mode ModeCortexRuntime.
Multi-mode handles per-mode field changes with dot-notation detection
(e.g. modes.scan.hertz) and correctly patches only the active mode's
RuntimeConfig while updating all ModeConfig objects.

Includes hertz validation (must be positive number) and clear logging
of what changed and which reload path was taken.
@Ridwannurudeen Ridwannurudeen requested review from a team as code owners February 10, 2026 05:37
@github-actions github-actions bot added robotics Robotics code changes python Python code tests Test files labels Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python code robotics Robotics code changes tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve hot-reload configs

1 participant