fix(issue-45): restore stays off when python3 has no tomllib

The shim runs a bare python3. Before 3.11 the module failed to import and the
server started with restore on; now it gets the key alone, with a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Opus 5.5 committed 2026-10-04 10:34:27 +00:00
1 parent feceddf49f
commit eedcebcc12
2 files changed
+16 -1

No files matched your search

+8 -1
View File
@@ -32,7 +32,6 @@ import os
import re
import sys
import tempfile
import tomllib
from typing import List, Mapping, Optional, Tuple
MARKER = "# generated by multi-agent-mux (Issue #45) - do not edit"
@@ -42,6 +41,11 @@ FALLBACK_NAME = "herdr-server-config.toml"
KEY = "resume_agents_on_restore"
MINIMAL = f"[session]\n{KEY} = false\n"
try:
import tomllib
except ImportError: # Python < 3.11: no parser to check a merge with
tomllib = None
_SESSION_HEADER = re.compile(r"^\s*\[\s*session\s*\]\s*(#.*)?$")
_ANY_HEADER = re.compile(r"^\s*\[")
_KEY_LINE = re.compile(rf"^\s*{KEY}\s*=")
@@ -107,6 +111,9 @@ def server_config_text(user_text: Optional[str]) -> Tuple[str, List[str]]:
always has session.resume_agents_on_restore = false."""
if not user_text or not user_text.strip():
return MINIMAL, []
if tomllib is None:
return MINIMAL, [f"this Python has no tomllib (3.11+); the MAM server uses only {KEY} = false, "
"without the rest of your settings"]
try:
user = tomllib.loads(user_text)
except tomllib.TOMLDecodeError as e: