Skip to content

The agent that grows with you

fix(gateway): post-merge seams — approval owner default, record_key projection, fanout drain import race

teknium17a258f0a1666
diff --git a/gateway/run_turn_runner.py b/gateway/run_turn_runner.py
index c4debde2ef6..0233b700908 100644
--- a/gateway/run_turn_runner.py
+++ b/gateway/run_turn_runner.py
@@ -75,12 +75,16 @@ from gateway.session_execution import GatewaySessionAgentMixin
class TurnRunner(GatewayTurnProgressMixin, GatewaySessionAgentMixin):
"""Per-turn collaborator carrying ``GatewayRunner._run_agent_inner``'s tool-progress callbacks."""
+ # ``None`` is a legitimate state: a turn with no owning session authority (messaging
+ # adapters without a canonical session) publishes no execution events and takes no
+ # controls snapshot. Class-level so every publish/snapshot seam can read it unconditionally.
+ _approval_owner = None
+
def __init__(self, runner: "GatewayRunner", ctx: TurnContext) -> None:
self._runner = runner
self._ctx = ctx
from gateway.session_authorities import active_authority
authority = active_authority(runner)
- self._approval_owner = None
if authority is not None:
source = getattr(ctx, 'source', None)
owner_id = (source.chat_id if getattr(source, 'platform', None) == Platform.LOCAL
diff --git a/gateway/session_config.py b/gateway/session_config.py
index ddf0de43102..b4df84afb40 100644
--- a/gateway/session_config.py
+++ b/gateway/session_config.py
@@ -36,12 +36,15 @@ def _authorize(connection, ref, params):
def _client_config(cfg):
# Native full-config consumers are presentation-only. Do not export provider,
# MCP, plugin or terminal configuration (which can contain arbitrary secrets).
- result = {key: cfg[key] for key in ('display', 'approvals', 'paste_collapse_threshold',
- 'paste_collapse_char_threshold') if key in cfg}
+ from hermes_cli.config import redact_config_value
+ result = redact_config_value({key: cfg[key] for key in (
+ 'display', 'approvals', 'paste_collapse_threshold', 'paste_collapse_char_threshold') if key in cfg})
+ # Allowlisted after redaction: ``record_key`` is a keybinding, not a credential, but the
+ # structural masker treats every ``*_key`` leaf as one. The voice section's real secrets
+ # (``api_key``) never enter the projection.
result['voice'] = {key: cfg.get('voice', {}).get(key) for key in ('record_key', 'submit_mode')
if key in cfg.get('voice', {})}
- from hermes_cli.config import redact_config_value
- return redact_config_value(result)
+ return result
async def config_get(connection, ref, params):
diff --git a/tui_gateway/transport.py b/tui_gateway/transport.py
index 5ee1cbb95a5..d3df8308d73 100644
--- a/tui_gateway/transport.py
+++ b/tui_gateway/transport.py
@@ -202,14 +202,17 @@ class FanoutTransport:
frame, size = peer.pending.popleft()
peer.pending_bytes -= size
try:
- from tui_gateway.ws import WSTransport
- if isinstance(peer.transport, WSTransport):
+ # Duck-typed on purpose: importing ``tui_gateway.ws`` here would pull
+ # ``tui_gateway.server`` in on this drain thread, racing any concurrent
+ # importer with a partially initialized module.
+ write_async = getattr(peer.transport, "write_async", None)
+ loop = getattr(peer.transport, "_loop", None)
+ if write_async is not None and loop is not None:
# write() acknowledges buffered tokens/timeouts, not socket
# progress. Await the real send so WS cannot move an
# unbounded backlog underneath this bounded mailbox.
from agent.async_utils import safe_schedule_threadsafe
- future = safe_schedule_threadsafe(
- peer.transport.write_async(frame), peer.transport._loop)
+ future = safe_schedule_threadsafe(write_async(frame), loop)
ok = future is not None and future.result()
else:
ok = peer.transport.write(frame)