The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui-gateway): carry session_id in the llm.oneshot runtime snapshot; align feasibility test
teknium14f0eea5e9491
diff --git a/tests/agent/test_compression_feasibility.py b/tests/agent/test_compression_feasibility.pyindex a6ba637e87c..1e0cdc998b0 100644--- a/tests/agent/test_compression_feasibility.py+++ b/tests/agent/test_compression_feasibility.py@@ -205,6 +205,7 @@ def test_feasibility_check_passes_live_main_runtime():"api_key": "codex-token","api_mode": "codex_responses","auth_mode": "",+ "session_id": "",},)diff --git a/tests/agent/test_opencode_session_affinity.py b/tests/agent/test_opencode_session_affinity.pyindex e38eaa70b11..f0fb4ad8bf8 100644--- a/tests/agent/test_opencode_session_affinity.py+++ b/tests/agent/test_opencode_session_affinity.py@@ -131,3 +131,20 @@ def test_async_out_of_turn_call_binds_the_explicit_main_runtime_session(monkeypaassert captured["extra_headers"]["x-opencode-session"] == "sess-affinity-1"assert aux._RUNTIME_MAIN_CONTEXT.get() is None+++def test_tui_gateway_oneshot_runtime_snapshot_carries_the_session(monkeypatch, out_of_turn):+ """The Desktop/TUI-gateway ``llm.oneshot`` path builds its explicit ``main_runtime`` from the live+ agent; without ``session_id`` an OpenCode title request sends no ``x-opencode-session`` (#112717)."""+ from tui_gateway.server import _main_runtime_from_agent++ agent = SimpleNamespace(+ provider="opencode-zen", model="glm-5", base_url="https://opencode.ai/zen/v1", api_key="test-key",+ api_mode="chat_completions", auth_mode="", session_id="sess-desktop-1",+ )+ captured = {}+ _route_to_fake_opencode_client(monkeypatch, captured, async_mode=False)++ aux.call_llm(task="title_generation", main_runtime=_main_runtime_from_agent(agent), messages=_MSGS)++ assert captured["extra_headers"]["x-opencode-session"] == "sess-desktop-1"diff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex 92d11d92513..b6303ea9e4f 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -2824,7 +2824,9 @@ def _main_runtime_from_agent(agent) -> dict | None:if agent is None:return Noneruntime: dict = {}- for field in ("provider", "model", "base_url", "api_key", "api_mode", "auth_mode"):+ # ``session_id`` rides along so a session-bound ``llm.oneshot`` (title, approval) on an OpenCode+ # route sends the conversation's ``x-opencode-session`` like the main turn does (#112717).+ for field in ("provider", "model", "base_url", "api_key", "api_mode", "auth_mode", "session_id"):value = getattr(agent, field, None)if isinstance(value, str) and value.strip():runtime[field] = value.strip()