fix: follow-up fixes for salvaged PRs

- Fix GatewayApp → GatewayRunner import in api_server.py (PR #4976)
- Update launchd test assertions for new bootstrap/bootout/kickstart commands (PR #4892)
- Add nonlocal message declaration in run_sync() to fix UnboundLocalError (pre-existing scoping bug)
This commit is contained in:
Teknium
2026-04-05 11:46:06 -07:00
committed by Teknium
parent 6a6ae9a5c3
commit 0c95e91059
3 changed files with 21 additions and 13 deletions

View File

@@ -423,8 +423,8 @@ class APIServerAdapter(BasePlatformAdapter):
# Load fallback provider chain so the API server platform has the
# same fallback behaviour as Telegram/Discord/Slack (fixes #4954).
from gateway.run import GatewayApp
fallback_model = GatewayApp._load_fallback_model()
from gateway.run import GatewayRunner
fallback_model = GatewayRunner._load_fallback_model()
agent = AIAgent(
model=model,

View File

@@ -6233,6 +6233,14 @@ class GatewayRunner:
logger.debug("status_callback error (%s): %s", event_type, _e)
def run_sync():
# The conditional re-assignment of `message` further below
# (prepending model-switch notes) makes Python treat it as a
# local variable in the entire function. `nonlocal` lets us
# read *and* reassign the outer `_run_agent` parameter without
# triggering an UnboundLocalError on the earlier read at
# `_resolve_turn_agent_config(message, …)`.
nonlocal message
# Pass session_key to process registry via env var so background
# processes can be mapped back to this gateway session
os.environ["HERMES_SESSION_KEY"] = session_key or ""