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(society): require routine saves and refresh agent card
rubenluetke10-beep3be35db70093
diff --git a/jarvis/brain/evidence_gate.py b/jarvis/brain/evidence_gate.pyindex d2f6c1adcc..9f9038d4e2 100644--- a/jarvis/brain/evidence_gate.py+++ b/jarvis/brain/evidence_gate.py@@ -296,8 +296,11 @@ def check_evidence_domain(if not t:return _PASSnormalised = _normalize(t)- if "society_propose_change" in live_tool_names and _CONFIGURATION_REQUEST.search(t):- return _PASS+ if "society_propose_change" in live_tool_names:+ from jarvis.society.routine_intent import requests_routine_creation++ if _CONFIGURATION_REQUEST.search(t) or requests_routine_creation(t):+ return _PASSif _DEFINITION_RE.search(normalised) and not _OWNERSHIP_RE.search(normalised):return _PASSif not _LOOKUP_SHAPE_RE.search(normalised):diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 7d1360ac7b..3cc2784dba 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -1869,6 +1869,17 @@ def _evidence_unfulfilled_answer(*, lang: str, domain: str = "") -> str:# to a write ("not saved yet"), not a failed lookup. Static, no LLM (AP-11);# localized for every supported language, unknown code → default locale._ACTION_UNFULFILLED_PHRASES: dict[str, dict[str, str]] = {+ "society_propose_change": {+ "de": (+ "Die Routine wurde nicht erstellt. " # i18n-allow: runtime output+ "Der Speichervorgang wurde nicht ausgeführt." # i18n-allow: runtime output+ ),+ "en": "The routine was not created. The save action did not run.",+ "es": (+ "La rutina no se creó. " # i18n-allow: runtime output+ "No se ejecutó la acción de guardarla." # i18n-allow: runtime output+ ),+ },"contact-upsert": {"de": ("Ich hab den Kontakt noch nicht gespeichert — sag mir die Angaben " # i18n-allow: German TTS@@ -11576,6 +11587,27 @@ class BrainManager:_local_mandate[0],)+ # A society model can describe a routine without ever calling its+ # configuration tool. Make the write mandatory on explicit creation+ # turns, including a short confirmation after the details were agreed.+ # The live surface check keeps this guard out of other chat surfaces.+ if not self._evidence_required_tool and "society_propose_change" in self._live_tool_names():+ from jarvis.society.routine_intent import requests_routine_creation++ if requests_routine_creation(user_text):+ self._evidence_directive = (+ "MANDATORY THIS TURN: the user asked you to CREATE a routine. "+ "Read existing routines with society_routines, then call "+ "society_propose_change with kind=routine and mode=apply. "+ "Use the current request and agreed conversation details; "+ "do not invent missing requirements. Verify the saved routine. "+ "If a prerequisite prevents saving it, say that it was not created."+ )+ self._evidence_required_tool = "society_propose_change"+ self._evidence_required_is_write = True+ self._evidence_required_domain = "routine"+ log.info("Society routine creation intent — mandating society_propose_change")+# Phase 5 / ADR-0006: pre-call budget gate. Block rather than request# when cooldown is active or the task/daily budget is exhausted.trace_uuid = turn_trace_iddiff --git a/jarvis/society/routine_intent.py b/jarvis/society/routine_intent.pynew file mode 100644index 0000000000..8d7e46d7a4--- /dev/null+++ b/jarvis/society/routine_intent.py@@ -0,0 +1,41 @@+"""Recognize explicit requests to create an agent routine in a chat turn."""++from __future__ import annotations++import re++from jarvis.skills.authoring_request import is_skill_authoring_request++_ROUTINE_NOUN = re.compile(r"\b(?:\w*routinen?|rutinas?)\b", re.IGNORECASE) # i18n-allow: input vocabulary+_CREATE_VERB = re.compile(+ r"\b(?:erstell\w*|anleg\w*|einricht\w*|creat\w*|set\s+up|" # i18n-allow: input vocabulary+ r"program\w*|configur\w*)\b",+ re.IGNORECASE,+)+_HOW_TO = re.compile(+ r"\b(?:wie\s+(?:kann|könnte|soll|würde|erstelle)|how\s+(?:do|can|to)|" # i18n-allow: input vocabulary+ r"cómo\s+(?:puedo|crear))\b",+ re.IGNORECASE,+)+_CONFIRMED_CREATE = re.compile(+ r"^\s*(?:bitte\s+|please\s+)?(?:erstell\w*|create|set\s+up|" # i18n-allow: input vocabulary+ r"configur\w*)\s+(?:mir\s+)?(?:die|diese|the|this)\s+routine\b",+ re.IGNORECASE,+)+_PAST_REPORT = re.compile(+ r"\b(?:wurde|war|was|were|had|habe|hatte)\s+\w*", # i18n-allow: input vocabulary+ re.IGNORECASE,+)+++def requests_routine_creation(text: str) -> bool:+ """Require a routine noun and creation intent; ignore how-to questions."""+ if not _ROUTINE_NOUN.search(text) or _HOW_TO.search(text):+ return False+ if _CONFIRMED_CREATE.search(text):+ return True+ return bool(+ _CREATE_VERB.search(text)+ and not _PAST_REPORT.search(text)+ and is_skill_authoring_request(text)+ )diff --git a/jarvis/ui/web/frontend/src/components/society/card/AgentRoutinesList.test.tsx b/jarvis/ui/web/frontend/src/components/society/card/AgentRoutinesList.test.tsxindex ead8bec34a..07a52c91c5 100644--- a/jarvis/ui/web/frontend/src/components/society/card/AgentRoutinesList.test.tsx+++ b/jarvis/ui/web/frontend/src/components/society/card/AgentRoutinesList.test.tsx@@ -3,10 +3,11 @@* through the society route, and a new row appears after save.*/import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";+import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";import { AgentRoutinesList } from "@/components/society/card/AgentRoutinesList";+import { notifyRoutineChanged } from "@/components/society/cardData";vi.mock("./AgentRoutineDetail", () => ({ AgentRoutineDetail: () => <div data-testid="routine-opened" /> }));@@ -75,6 +76,21 @@ describe("AgentRoutinesList", () => {expect(screen.getByTestId("agent-routines").textContent).not.toContain("[agent:Mailbox]");});+ test("a routine created in chat appears immediately in the open card", async () => {+ mount();+ await screen.findByRole("button", { name: "Morning inbox" });+ routines.push({+ id: "r-chat",+ title: "[agent:Mailbox] GitHub issues",+ state: "scheduled",+ trigger: { kind: "calendar", local_time: "08:00", timezone: "Europe/Berlin" },+ });+ act(() => notifyRoutineChanged("mailbox"));+ await screen.findByRole("button", { name: "GitHub issues" });+ expect(fetchMock.mock.calls.filter(([url]) => String(url).includes("/routines")).length)+ .toBeGreaterThan(1);+ });+test.each(["schedule", "next-run", "icon", "padding"])("opens the routine when clicking %s", async (area) => {routines[0].due_at_ns = Date.UTC(2026, 8, 13, 8) * 1e6;mount();diff --git a/jarvis/ui/web/frontend/src/components/society/cardData.ts b/jarvis/ui/web/frontend/src/components/society/cardData.tsindex f4de52f3cd..cbe3548257 100644--- a/jarvis/ui/web/frontend/src/components/society/cardData.ts+++ b/jarvis/ui/web/frontend/src/components/society/cardData.ts@@ -13,9 +13,16 @@ export { describeTrigger } from "@/lib/triggerDescription";* every one of them returns an empty list when the backend is not there. The* card treats them as enrichment and never blocks on them.*/-import { useCallback } from "react";+import { useCallback, useEffect } from "react";import { useQuery, useQueryClient } from "@tanstack/react-query";+const routineListeners = new Set<(agentId: string) => void>();++/** Tell an open routines card that a chat action changed its stored tasks. */+export function notifyRoutineChanged(agentId: string): void {+ for (const listener of routineListeners) listener(agentId);+}+/** One line of what the agent did or was told, from the society event log. */export interface AgentActivity {id: string;@@ -168,6 +175,16 @@ export function useAgentSkills(agentId: string | null) {/** The agent's scheduled tasks, as the Automations store actually holds them. */export function useAgentRoutines(agentId: string | null) {+ const client = useQueryClient();+ useEffect(() => {+ const refresh = (changedAgentId: string) => {+ if (changedAgentId !== agentId) return;+ void client.invalidateQueries({ queryKey: ["society", "agent-routines", agentId] });+ void client.invalidateQueries({ queryKey: ["tasks"] });+ };+ routineListeners.add(refresh);+ return () => { routineListeners.delete(refresh); };+ }, [agentId, client]);return useQuery({queryKey: ["society", "agent-routines", agentId],enabled: Boolean(agentId),diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsxindex 2fe1d27846..6a735d2375 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.switch.test.tsx@@ -15,6 +15,7 @@ import { useEventStore } from "@/store/events";import type { AgentChatEvent, AgentChatSession } from "@/lib/agentChatApi";import { useHomeStore } from "@/store/home";import { JarvisHistoryRail } from "./JarvisHistoryRail";+import * as cardData from "../cardData";vi.mock("@/i18n", () => ({ useT: () => (key: string) => key, fill: (text: string) => text }));vi.mock("./AgentModelPicker", () => ({ AgentModelPicker: () => null }));@@ -139,6 +140,19 @@ it("hides another session's items until that session is the open one", () => {expect(itemsForOpenSession(null, "society:visual-qa", visualItems)).toEqual([]);});+it("refreshes the agent's routines when a chat save succeeds", async () => {+ const notify = vi.spyOn(cardData, "notifyRoutineChanged");+ const timeline = reduceEvents(EMPTY_TIMELINE, [+ ev("turn_started", { turn_id: "routine-turn", provider: "ollama", model: "local", runner: "brain" }),+ ev("tool_call", { turn_id: "routine-turn", call_id: "save-routine", name: "society_propose_change", input: { kind: "routine", mode: "apply" } }),+ ev("tool_result", { turn_id: "routine-turn", call_id: "save-routine", output: "routine scheduled", is_error: false }),+ ]);+ useSocietyChatStore.setState({ activeSessionId: visual.chatSessionId, timeline });+ render(<AgentChatPanel agent={visual} roster={[visual]} />);+ await waitFor(() => expect(notify).toHaveBeenCalledWith(visual.agentId));+ notify.mockRestore();+});+it("does not paint the previous specialist's transcript after a click onto another agent", () => {useSocietyChatStore.setState({activeSessionId: visual.chatSessionId,diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsxindex 87ff0af951..24d9a2d43b 100644--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentChatPanel.tsx@@ -23,6 +23,7 @@ import { mergeOutgoingMessages, useOutgoingMessages } from "@/components/agentch* runner can drive. The header says so while voice is showing.*/import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";+import { notifyRoutineChanged } from "../cardData";import { MessageSquare, Mic, Paperclip, Plus, RotateCcw, Send, Square } from "lucide-react";import { ChatMarkdown, MediaPreview, mediaKind } from "@/components/agentchat/ChatMarkdown";@@ -187,6 +188,27 @@ function SpecialistChat({ agent, roster }: AgentChatPanelProps) {const sessionId = agent.chatSessionId;const sessionReady = Boolean(sessionId) && activeSessionId === sessionId;const visibleItems = itemsForOpenSession(sessionId, activeSessionId, items);+ const refreshedRoutineReceipts = useRef(new Set<string>());+ useEffect(() => {+ for (const item of visibleItems) {+ if (item.type === "turn") {+ for (const block of item.blocks) {+ if (block.kind !== "tool" || block.name !== "society_propose_change" || block.output === null || block.isError) continue;+ const input = block.input as { kind?: string; mode?: string } | null;+ if (input?.kind !== "routine" || input.mode !== "apply") continue;+ const key = `tool:${block.callId}`;+ if (refreshedRoutineReceipts.current.has(key)) continue;+ refreshedRoutineReceipts.current.add(key);+ notifyRoutineChanged(agent.agentId);+ }+ } else if (item.type === "notice" && item.kind === "proposal" && item.resolved === "applied" && item.data.proposal_kind === "routine") {+ const key = `proposal:${item.id}`;+ if (refreshedRoutineReceipts.current.has(key)) continue;+ refreshedRoutineReceipts.current.add(key);+ notifyRoutineChanged(agent.agentId);+ }+ }+ }, [visibleItems, agent.agentId]);const outgoing = useOutgoingMessages(sessionReady ? agent.agentId : null);const allItems = useMemo(() => mergeOutgoingMessages(visibleItems, outgoing, agent.agentId, agent.name,diff --git a/tests/contract/test_society_continuity.py b/tests/contract/test_society_continuity.pyindex e6da1b9754..0db1987f79 100644--- a/tests/contract/test_society_continuity.py+++ b/tests/contract/test_society_continuity.py@@ -337,6 +337,13 @@ def test_configuration_capability_does_not_unlock_actual_data_lookup():)+def test_routine_creation_uses_the_configuration_tool_not_a_github_read_mandate():+ from tests.unit.brain.test_evidence_gate import _gate++ request = "Erstelle eine Routine für GitHub Issues." # i18n-allow: input fixture+ assert _gate(request, live_tools=("society_propose_change",)).kind == "pass"++def test_live_capabilities_include_filtered_turn_tools():from jarvis.brain.manager import _TURN_OVERRIDE, BrainManagerfrom jarvis.brain.turn_override import TurnOverridediff --git a/tests/unit/society/test_routine_intent.py b/tests/unit/society/test_routine_intent.pynew file mode 100644index 0000000000..7fa3427b99--- /dev/null+++ b/tests/unit/society/test_routine_intent.py@@ -0,0 +1,44 @@+"""Explicit routine requests must demand an actual save action."""++import pytest++from jarvis.brain.manager import _unfulfilled_replacement+from jarvis.society.routine_intent import requests_routine_creation+++ "utterance",+ [+ "Kannst du mir eine Routine erstellen?", # i18n-allow: input fixture+ "Erstelle die Routine.", # i18n-allow: input fixture+ "Create a daily routine that checks GitHub issues.",+ ],+)+def test_explicit_routine_creation_is_recognized(utterance: str) -> None:+ assert requests_routine_creation(utterance)+++ "utterance",+ [+ "Wie erstelle ich eine Routine?", # i18n-allow: input fixture+ "Die Routine wurde erstellt.", # i18n-allow: input fixture+ "Show my routines.",+ "Create a skill for daily checks.",+ ],+)+def test_non_creation_turns_do_not_trigger_a_write(utterance: str) -> None:+ assert not requests_routine_creation(utterance)+++def test_unexecuted_routine_write_cannot_look_successful() -> None:+ answer = _unfulfilled_replacement(+ required_tool="society_propose_change",+ executed=set(),+ response_text="I will create your daily routine now.",+ suppressed=False,+ is_write=True,+ lang="en",+ domain="routine",+ )+ assert answer == "The routine was not created. The save action did not run."