CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m14s
Development Plan M1.1, as discussed. - Schema v4: a work_items table (id, scope, title, status, outcome, position, data) and an agent row whose active_item points at one (NULL: idle). Canonical events and intents carry their work item, and events their actor. Older stores are refused with a clear message: there was no production data, so no migration (the mechanism stays). - The log is reached through a Transcript bound to one work item and one actor: store.transcript(item, actor) reads only that item and writes with both. The planner, executor, delegation and expert desk get one per call from the orchestrator instead of holding the store, so a component can neither read another task's events (the planner read every earlier task's, #78) nor write without attribution. store.all_events() is kept for readers that span items (evaluation capture, dumps). Intents are begun through the transcript or with work_item=, so each belongs to its item. - The orchestrator opens a work item on 'use', closes it with its outcome (completed or abandoned), and carries what the operator said while idle into the new item as copies with their origin, so a task sent before 'use' is still planned from (D1). control.py keeps its state machine through get_state()/transition(), now over the active work item, until M2.6 retires it. - nisse_dev.dump shows work items and each event's item and actor. Tests: test_work_items.py (scoping, attribution, intent ownership, restart, outcomes, carried messages, a second task never seeing the first); the suites updated for the per-call transcript. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
"""A real consult over the normalized route (L9).
|
|
|
|
The point is the prompt-level contract: a live model must produce something
|
|
that parses against our local schema, since no API-level enforcement exists.
|
|
"""
|
|
|
|
import io
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from nisse_dev.evals import collect
|
|
from nisse_dev.expert import BudgetExhausted, ExpertDesk
|
|
from nisse_dev.llm import LiteLLMClient, RoleMap
|
|
from nisse_dev.oplog import OpLog
|
|
from nisse_dev.state import StateStore
|
|
|
|
pytestmark = pytest.mark.integration
|
|
|
|
|
|
@pytest.fixture
|
|
def desk(tmp_path: Path, litellm: LiteLLMClient, live_model: str):
|
|
def make(budget: int = 2) -> tuple[ExpertDesk, StateStore]:
|
|
model = live_model
|
|
roles = RoleMap(executor=model, planner=model, helper=model, expert=model)
|
|
store = StateStore(
|
|
tmp_path / "state.db", oplog=OpLog("nisse-dev", io.StringIO())
|
|
)
|
|
return ExpertDesk(litellm, roles, budget=budget), store
|
|
|
|
return make
|
|
|
|
|
|
def test_live_consult_parses_against_the_local_schema(desk) -> None:
|
|
expert, store = desk()
|
|
|
|
answer = expert.ask(
|
|
store.transcript("t", "expert"),
|
|
"For a single-process agent storing a few thousand rows of task state, "
|
|
"is SQLite sufficient, or is PostgreSQL warranted? Answer briefly.",
|
|
)
|
|
|
|
assert answer.confidence in {"high", "medium", "low"}
|
|
assert len(answer.answer) > 20
|
|
# The consult is captured for L9 without any extra bookkeeping.
|
|
[record] = collect(store)
|
|
assert record.role == "expert"
|
|
assert record.exit_status == "answered"
|
|
|
|
|
|
def test_live_budget_stops_a_circling_caller(desk) -> None:
|
|
expert, store = desk(budget=1)
|
|
expert.ask(
|
|
store.transcript("t", "expert"),
|
|
"Name one advantage of WAL mode in SQLite. Be brief.",
|
|
)
|
|
with pytest.raises(BudgetExhausted):
|
|
expert.ask(store.transcript("t", "expert"), "And another?")
|