Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(gateway): take the effort ladder from ReasoningEffort (#1085)
Ruben Lütke5f882fdda634
diff --git a/dodaios/agent_runtimes/gateway.py b/dodaios/agent_runtimes/gateway.pyindex 037188ee29..63db73b25d 100644--- a/dodaios/agent_runtimes/gateway.py+++ b/dodaios/agent_runtimes/gateway.py@@ -43,9 +43,10 @@ from collections.abc import AsyncIterator, Iteratorfrom concurrent.futures import Futurefrom dataclasses import dataclass, replacefrom email.utils import parsedate_to_datetime-from typing import Any, Final+from typing import Any, Final, get_argsfrom dodaios.agent_runtimes.model_limits import ModelLimits, resolve_limits+from dodaios.core.protocols import ReasoningEffortlog = logging.getLogger(__name__)@@ -166,9 +167,9 @@ def _final_finish(finish: str, calls: int) -> str:runtimes retry it with a larger budget instead of running it."""return "tool_calls" if calls and finish == "stop" else finish-_EFFORTS: Final[frozenset[str]] = frozenset(- {"none", "minimal", "low", "medium", "high", "xhigh", "max"}-)+# The shared ladder, not a copy of it: a level added there (``ultra``, #1060)+# must reach the provider instead of being dropped here as unknown.+_EFFORTS: Final[frozenset[str]] = frozenset(get_args(ReasoningEffort))def grant_token(diff --git a/dodaios/agent_runtimes/manager.py b/dodaios/agent_runtimes/manager.pyindex d835763671..15e6002c83 100644--- a/dodaios/agent_runtimes/manager.py+++ b/dodaios/agent_runtimes/manager.py@@ -397,7 +397,14 @@ async def _run_process(creationflags=NO_WINDOW_CREATIONFLAGS,start_new_session=True,)- tree.assign(proc.pid)+ try:+ tree.assign(proc.pid)+ except OSError as exc:+ # Windows refuses a process that already exited (a fast+ # command can finish before this line). The command did+ # start, so its exit code below is the outcome, not this.+ log.debug("agent runtimes: %s %s not contained: %s",+ current.runtime, current.kind, exc)try:code = await asyncio.wait_for(proc.wait(), timeout=_JOB_TIMEOUT_S)except TimeoutError: # reported through the job's state and message belowdiff --git a/tests/unit/agent_runtimes/test_runtime_gateway.py b/tests/unit/agent_runtimes/test_runtime_gateway.pyindex e1a2ce9751..71e3a2cc62 100644--- a/tests/unit/agent_runtimes/test_runtime_gateway.py+++ b/tests/unit/agent_runtimes/test_runtime_gateway.py@@ -11,13 +11,14 @@ import jsonimport timefrom collections.abc import AsyncIteratorfrom types import SimpleNamespace-from typing import Any+from typing import Any, get_argsimport pytestfrom fastapi import FastAPIfrom fastapi.testclient import TestClientfrom dodaios.agent_runtimes import gateway+from dodaios.core.protocols import ReasoningEffortfrom dodaios.live.subscription_reasoning import SubscriptionReasoningErrorfrom dodaios.ui.web.runtime_gateway_routes import routerfrom dodaios.ui.web.surface_security import SurfaceSecurity@@ -1032,3 +1033,25 @@ def test_a_later_answer_clears_the_kept_failure() -> None:gateway._answered(signal)assert gateway.last_failure(signal) == ""gateway._answered(None)++[email protected]("effort", sorted(get_args(ReasoningEffort)))+def test_every_shared_effort_level_reaches_the_provider(effort: str) -> None:+ """The gateway keeps no ladder of its own (#1060): every level of the shared+ ``ReasoningEffort`` — ``ultra`` included once it is there — passes through,+ on the request body and on the runner's per-turn effort alike."""+ _, request = gateway.chat_request({**_CHAT, "reasoning_effort": effort})+ assert request.reasoning_effort == effort++ token = gateway.grant_token("effort-probe", "openai")+ signal = gateway.watch_failure(token, effort=effort)+ try:+ grant = gateway._GRANTS[token]+ assert gateway._turn_effort(grant) == effort+ finally:+ gateway.unwatch_failure(token, signal)+++def test_an_unknown_effort_level_is_dropped() -> None:+ _, request = gateway.chat_request({**_CHAT, "reasoning_effort": "turbo"})+ assert request.reasoning_effort is Nonediff --git a/tests/unit/agent_runtimes/test_runtime_manager.py b/tests/unit/agent_runtimes/test_runtime_manager.pyindex 10c9b207de..0e353c0309 100644--- a/tests/unit/agent_runtimes/test_runtime_manager.py+++ b/tests/unit/agent_runtimes/test_runtime_manager.py@@ -537,3 +537,24 @@ def test_the_windows_openclaw_install_runs_npm_scripts_on_the_private_node(monkenode_dir = str(openclaw.cli_prefix() / "node")path_set = text.index("$env:Path = '" + node_dir + ";'")assert path_set < text.index("npm-cli.js")+++async def test_a_command_that_exits_before_containment_still_reports_its_exit_code(+ fakes, monkeypatch+):+ """Windows refuses to put an already-exited process in a job object+ (ACCESS_DENIED). The command did run: its exit code is the outcome."""+ from dodaios.core import process_tree++ class _ExitedTree:+ def assign(self, pid: int) -> None:+ raise PermissionError(13, "Access is denied")++ def close(self) -> None:+ return None++ monkeypatch.setattr(process_tree, "make_process_tree", lambda name: _ExitedTree())+ await manager.start("openclaw", "update")+ done = await _finish("openclaw")+ assert done.state == "failed" and done.exit_code == 3+ assert "Could not start" not in done.message