Skip to content

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.

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.py
index 037188ee29..63db73b25d 100644
--- a/dodaios/agent_runtimes/gateway.py
+++ b/dodaios/agent_runtimes/gateway.py
@@ -43,9 +43,10 @@ from collections.abc import AsyncIterator, Iterator
from concurrent.futures import Future
from dataclasses import dataclass, replace
from email.utils import parsedate_to_datetime
-from typing import Any, Final
+from typing import Any, Final, get_args
from dodaios.agent_runtimes.model_limits import ModelLimits, resolve_limits
+from dodaios.core.protocols import ReasoningEffort
log = 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.py
index 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 below
diff --git a/tests/unit/agent_runtimes/test_runtime_gateway.py b/tests/unit/agent_runtimes/test_runtime_gateway.py
index 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 json
import time
from collections.abc import AsyncIterator
from types import SimpleNamespace
-from typing import Any
+from typing import Any, get_args
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from dodaios.agent_runtimes import gateway
+from dodaios.core.protocols import ReasoningEffort
from dodaios.live.subscription_reasoning import SubscriptionReasoningError
from dodaios.ui.web.runtime_gateway_routes import router
from 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 None
diff --git a/tests/unit/agent_runtimes/test_runtime_manager.py b/tests/unit/agent_runtimes/test_runtime_manager.py
index 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(monke
node_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