What isn't the dev agent's moves to nisse-core, unchanged in behaviour, with its tests: canonical, render, render_anthropic, llm, catalog, probe, context, views, state, reconcile, worker, cancel, dump, transport, matrix, execution, testing, vault, memory, oplog, envfile and gitea (whole). - nisse_core.state.StateStore holds the tables every agent has; an agent's subclass adds its tables (version, migrations), roles and views. nisse_dev.state.StateStore adds the build VM blocks (v5). - views.project takes what each role is shown, rather than a fixed table. - Vault takes the agent's name (agent=), for provenance. - A test that nisse_core never imports an agent. - The loop, config, git, delegation, expert, tools and evals stay in nisse-dev until nisse-ops has a loop to share. Docs: the Development Plan marks M7.1 done and notes that Phase 6 waits on the agent host and Terraform; Architecture Part L names the package. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""The operator's kill switch, as the working loops see it (architecture L2).
|
|
|
|
`stop` has to reach work that is already running, from a thread that is not
|
|
running it. So it is a flag, set by whoever hears the command and checked by
|
|
the loops at each tool boundary. Setting it touches nothing durable: the
|
|
record of a stop is written by the worker when the stopped work returns.
|
|
"""
|
|
|
|
import threading
|
|
|
|
from nisse_core.canonical import ToolCall, ToolResult
|
|
from nisse_core.state import Transcript
|
|
|
|
STOPPED_RESULT = "not run: the operator stopped the agent"
|
|
|
|
|
|
class Cancel:
|
|
def __init__(self) -> None:
|
|
self._event = threading.Event()
|
|
|
|
def set(self) -> None:
|
|
self._event.set()
|
|
|
|
def clear(self) -> None:
|
|
self._event.clear()
|
|
|
|
@property
|
|
def requested(self) -> bool:
|
|
return self._event.is_set()
|
|
|
|
|
|
def skip_calls(
|
|
transcript: Transcript, calls: list[ToolCall], reason: str = STOPPED_RESULT
|
|
) -> None:
|
|
"""Record calls left unrun. Every tool call needs a result for the
|
|
transcript to render again, and the result says what happened."""
|
|
for call in calls:
|
|
transcript.append(
|
|
ToolResult(call_id=call.call_id, result=reason, success=False)
|
|
)
|