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(society): keep an agent's own safe tools on a runtime cache miss

rubenluetke10-beepc3ba99ac1bcd
diff --git a/jarvis/society/surface.py b/jarvis/society/surface.py
index 924d1d0252..8b2d57d402 100644
--- a/jarvis/society/surface.py
+++ b/jarvis/society/surface.py
@@ -528,11 +528,16 @@ def society_tool_filter(session: Any) -> Callable[[dict[str, Tool]], dict[str, T
return None
agent = rt.cached_agent(agent_id)
if agent is None:
- # The briefing fills the cache before the override is built; a miss
- # means a turn without a briefing — keep the own hands, deny the rest
- # of the write paths the agent must not have.
+ # The briefing fills the cache before the override is built. A miss (a
+ # turn that skipped the briefing, a runtime restart mid-session) cannot
+ # establish the agent's mode or grants, so no granted hand and no write
+ # is offered. Its own safe society tools stay: without them it can
+ # neither report back nor ask the user, and the job stalls silently
+ # (#255).
return lambda tools: {
- n: t for n, t in tools.items() if n.startswith(_OWN_PREFIX) or n not in _SOCIETY_DENIED
+ n: t
+ for n, t in tools.items()
+ if n.startswith(_OWN_PREFIX) and getattr(t, "risk_tier", "monitor") == "safe"
}
def _apply(tools: dict[str, Tool]) -> dict[str, Tool]:
diff --git a/tests/unit/society/test_surface.py b/tests/unit/society/test_surface.py
index 7d484e1713..949594e658 100644
--- a/tests/unit/society/test_surface.py
+++ b/tests/unit/society/test_surface.py
@@ -226,3 +226,25 @@ async def test_always_allow_writes_the_agents_own_rule(rt: SocietyRuntime):
assert (await rt.roster.get("mailbox")).approval_rules["always_allow"] == ["plugin:gmail:send"]
assert await remember_always_allow(session, "spawn-worker", {}) is False
assert await remember_always_allow(SimpleNamespace(session_id="agent:x"), "gmail", {}) is False
+
+
+async def test_a_cache_miss_keeps_the_agents_own_reporting_tools(
+ rt: SocietyRuntime, tmp_path: Path
+):
+ """#255: a turn without the briefing (a CLI/MCP turn, a runtime restart)
+ finds no cached record. Its mode and grants are unknown, so no granted
+ hand and no write — but stripping its own safe tools left it unable to
+ report back or ask the user, and the job stalled silently."""
+ await rt.roster.create(name="Courier", title="Runner", description="Run errands.")
+ cfg = SimpleNamespace(wiki=SimpleNamespace(vault_root=str(tmp_path / "vault")))
+ session = SimpleNamespace(session_id="society:courier")
+ own = society_tools(cfg, None, session)
+ assert rt.cached_agent("courier") is None, "no briefing ran"
+
+ filt = society_tool_filter(session)
+ assert filt is not None
+ picked = set(filt({**TOOLS, **own}))
+
+ assert {MESSAGE_TOOL_NAME, "society_ask_user", MEMORY_RECALL_TOOL_NAME} <= picked
+ assert SHELL_TOOL_NAME not in picked and WIKI_NOTE_TOOL_NAME not in picked, "no writes"
+ assert not picked & set(TOOLS), "no granted hands while the grants are unknown"