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(missions): a denied tool call is a setback, not a lost mission

Ruben Lütke08e658e908a6
diff --git a/jarvis/missions/kontrollierer/orchestrator.py b/jarvis/missions/kontrollierer/orchestrator.py
index 54876a6206..2bea6598f2 100644
--- a/jarvis/missions/kontrollierer/orchestrator.py
+++ b/jarvis/missions/kontrollierer/orchestrator.py
@@ -1438,8 +1438,9 @@ class Kontrollierer:
),
}
logger.error(
- "Task %s iter %d: refusing critic review after an unclean "
- "supervisor tool grant: %s",
+ "Task %s iter %d: refusing critic review after an "
+ "integrity-compromised supervisor tool grant (a call was "
+ "still running or its outcome is unknown): %s",
step.task_id,
iteration,
error_detail,
@@ -1656,13 +1657,28 @@ class Kontrollierer:
if safety_kill_reason is not None:
return TaskOutcome.ERROR
- # Critic-Call
+ # Critic-Call. Honest supervisor-tool refusals (denied/timed-out/
+ # errored calls the worker OBSERVED in-stream) did not abort the
+ # iteration — only integrity failures do — but the critic must
+ # judge the deliverable WITH the refusal list: "the task depended
+ # on the denied call" is a reject, "the worker adapted" is not
+ # (BUG-096: execution, artifact, approval, and outcome are four
+ # separate facts). Appended to the critic's log view only, never
+ # to the diff, and after the safety scan so the scanner never
+ # reads our own note.
+ critic_log = log_text
+ if spawn_result.supervisor_tool_refusals:
+ critic_log = (
+ f"{log_text}\n\n"
+ "# supervisor-tool refusals (observed by the worker)\n"
+ f"{spawn_result.supervisor_tool_refusals}\n"
+ )
env = self._env_builder(mission_dir)
try:
verdict = await self._runner.run(
mission_prompt=mission_prompt,
worker_diff=diff_text,
- worker_log=log_text,
+ worker_log=critic_log,
prior_reflections=prior_block,
iteration=iteration,
worktree=worktree,
@@ -1810,6 +1826,7 @@ class Kontrollierer:
worker_timed_out: bool = False,
supervisor_tool_failed: bool = False,
supervisor_tool_error: str | None = None,
+ supervisor_tool_refusals: str | None = None,
) -> None:
self.worker_id = worker_id
self.cost_usd = cost_usd
@@ -1830,6 +1847,10 @@ class Kontrollierer:
self.worker_error = worker_error
self.supervisor_tool_failed = supervisor_tool_failed
self.supervisor_tool_error = supervisor_tool_error
+ # Observed refusals (denied/timed_out/error/cancelled) — the
+ # worker saw these in-stream and could adapt; they do NOT fail
+ # the iteration, they inform the critic (BUG-096 four facts).
+ self.supervisor_tool_refusals = supervisor_tool_refusals
async def _spawn_worker_collect(
self,
@@ -2037,8 +2058,12 @@ class Kontrollierer:
session_id=session_id,
worker_error=worker_error,
worker_timed_out=worker_timed_out,
- supervisor_tool_failed=not broker_summary.clean,
+ # Only INTEGRITY failures (outcome_unknown / still-active calls)
+ # abort the iteration — an observed refusal keeps the work
+ # reviewable and reaches the critic as context instead.
+ supervisor_tool_failed=broker_summary.integrity_compromised,
supervisor_tool_error=broker_summary.failure_summary,
+ supervisor_tool_refusals=broker_summary.refusal_summary,
)
# --- Phase-5 Safety -----------------------------------------------------
diff --git a/jarvis/missions/workers/api_agent_worker.py b/jarvis/missions/workers/api_agent_worker.py
index 25c9ddf629..a2fcde8fc7 100644
--- a/jarvis/missions/workers/api_agent_worker.py
+++ b/jarvis/missions/workers/api_agent_worker.py
@@ -177,7 +177,10 @@ _SYSTEM_PROMPT = (
"workspace. Your ONLY way to deliver work is to call the provided tools — "
"Write, Edit, Read, RunCommand, Ls, plus any mission-scoped connected tools — "
"with file paths relative to the workspace root. Connected tools are "
- "executed by the supervisor and may honestly require human approval. "
+ "executed by the supervisor and may honestly require human approval; a "
+ "denied or failed connected-tool call is a normal, recoverable event - "
+ "adapt, use an alternative, or deliver the remainder and state the "
+ "limitation in your summary. "
"Actually CREATE and EDIT the files the task needs; never just describe what "
"you would do (a text description is not a deliverable and will be rejected). "
"Work autonomously without asking questions: if a detail is unspecified, pick "
diff --git a/tests/contract/test_brain_protocol.py b/tests/contract/test_brain_protocol.py
index acff352f8a..29788ec9e0 100644
--- a/tests/contract/test_brain_protocol.py
+++ b/tests/contract/test_brain_protocol.py
@@ -21,8 +21,9 @@ BRAIN_PROVIDERS = [
"openrouter",
"openai",
"gemini",
- # Keyless local provider, re-added 2026-07-25 (local-first mandate).
+ # Keyless local providers, added 2026-07-25 (local-first mandate).
"ollama",
+ "local-openai",
]
diff --git a/tests/missions/kontrollierer/test_supervisor_tool_completion_gate.py b/tests/missions/kontrollierer/test_supervisor_tool_completion_gate.py
index d1b8b47738..007e410ec6 100644
--- a/tests/missions/kontrollierer/test_supervisor_tool_completion_gate.py
+++ b/tests/missions/kontrollierer/test_supervisor_tool_completion_gate.py
@@ -1,4 +1,14 @@
-"""The critic cannot approve past an unclean supervisor-tool grant."""
+"""Supervisor-tool completion certificate: integrity gates, refusals inform.
+
+Two failure classes, two different consequences (BUG-096 four-facts rule):
+
+* INTEGRITY failures (a call still running when the grant closed /
+ ``outcome_unknown``) — the supervisor cannot certify what happened, so the
+ iteration is aborted and the critic never runs.
+* OBSERVED refusals (denied / timed-out / errored calls) — the worker saw the
+ error in-stream and could adapt, so the iteration stays reviewable and the
+ critic receives the refusal list as context.
+"""
from __future__ import annotations
@@ -126,10 +136,12 @@ def _clean_runtime_refs() -> Any:
@pytest.mark.asyncio
-async def test_worker_cannot_hide_failed_tool_call_from_approving_critic(
+async def test_observed_tool_error_reaches_critic_with_refusal_note(
manager: MissionManager,
tmp_path: Path,
) -> None:
+ """A tool ERROR the worker observed in-stream no longer kills the
+ iteration — the critic reviews the work WITH the refusal as context."""
gateway = _Gateway(
ToolResult(success=False, output=None, error="connector unavailable")
)
@@ -146,14 +158,74 @@ async def test_worker_cannot_hide_failed_tool_call_from_approving_critic(
state = await kontrollierer.run_mission(mission_id)
- assert state == MissionState.FAILED
- assert critic.calls == []
+ assert state == MissionState.APPROVED
assert gateway.calls == 1
+ assert len(critic.calls) == 1
+ critic_log = critic.calls[0]["worker_log"]
+ assert "supervisor-tool refusals" in critic_log
+ assert "external-action" in critic_log
+ assert "connector unavailable" in critic_log
+
+
+async def test_denied_tool_call_reaches_critic_and_is_named(
+ manager: MissionManager,
+ tmp_path: Path,
+) -> None:
+ """An approval denial (e.g. the unattended 60 s timeout) is an observed
+ refusal: the mission is graded, not auto-failed as supervisor_tool_failed."""
+ gateway = _Gateway(
+ ToolResult(success=False, output=None, error="approval-denied (timeout)")
+ )
+ runtime_refs.set_supervisor_tool_gateway(gateway)
+ worker = _BrokerCallingWorker()
+ critic = FakeCriticRunner(_make_approve_verdict())
+ kontrollierer = _make_kontrollierer(
+ manager=manager,
+ tmp_path=tmp_path,
+ critic=critic,
+ worker_factory_fn=lambda _step: worker,
+ )
+ mission_id = await manager.dispatch(prompt="Perform an external action")
+
+ state = await kontrollierer.run_mission(mission_id)
+
+ assert state == MissionState.APPROVED
+ assert len(critic.calls) == 1
+ critic_log = critic.calls[0]["worker_log"]
+ assert "denied" in critic_log
events = await manager.store.events_for_mission(mission_id)
- approved = [e for e in events if e.payload.event_type == "MissionApproved"]
failed = [e for e in events if e.payload.event_type == "MissionFailed"]
- assert approved == []
- assert failed[-1].payload.error_class == "supervisor_tool_failed" # type: ignore[union-attr]
+ assert failed == []
+
+
+def test_summary_partitions_refusals_from_integrity_failures() -> None:
+ """Every non-success status belongs to exactly one bucket: observed
+ refusal (keeps the iteration reviewable) or integrity failure (gates)."""
+ from jarvis.missions.workers.worker_tool_broker import (
+ WorkerToolCallOutcome,
+ WorkerToolExecutionSummary,
+ )
+
+ def call(status: str) -> WorkerToolCallOutcome:
+ return WorkerToolCallOutcome(trace_id="t", tool_name="x", status=status) # type: ignore[arg-type]
+
+ refusals = WorkerToolExecutionSummary(
+ calls=(call("denied"), call("error"), call("timed_out"), call("cancelled"))
+ )
+ assert refusals.clean is False
+ assert refusals.integrity_compromised is False
+ assert "denied" in (refusals.refusal_summary or "")
+
+ for status in ("outcome_unknown", "active"):
+ summary = WorkerToolExecutionSummary(calls=(call(status),))
+ assert summary.integrity_compromised is True
+ assert summary.refusal_summary is None
+
+ clean = WorkerToolExecutionSummary(calls=(call("success"),))
+ assert clean.clean is True
+ assert clean.integrity_compromised is False
+ assert clean.refusal_summary is None
@pytest.mark.asyncio
diff --git a/tests/unit/missions/test_api_agent_worker_providers.py b/tests/unit/missions/test_api_agent_worker_providers.py
index 5f1139126c..78a9f25859 100644
--- a/tests/unit/missions/test_api_agent_worker_providers.py
+++ b/tests/unit/missions/test_api_agent_worker_providers.py
@@ -25,5 +25,13 @@ def test_gemini_has_in_process_worker():
def test_every_api_agent_provider_has_a_default_model():
+ from jarvis.brain.app_control import LOCAL_PROVIDERS
+
for provider in _BRAIN_BY_PROVIDER:
+ if provider in LOCAL_PROVIDERS:
+ # Local servers have no knowable catalog ahead of time — no
+ # documented default; the plugin discovers the first installed
+ # model itself (_resolve_worker_model falls to "" → discovery).
+ assert _DEFAULT_MODEL.get(provider) is None
+ continue
assert _DEFAULT_MODEL.get(provider), f"{provider} has no documented default model"