mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* refactor(usage): remove the unconsumed per-agent USAGE_UPDATE event USAGE_UPDATE was published per active agent each sweep, bridged, and broadcast to /ws/system, but no panel client ever consumed it — the dashboard reads only the aggregate USAGE_SNAPSHOT. Every emission was wasted event-bus and WebSocket traffic. Drop the UsageUpdate payload, publish_usage_update and its throttle, the EventType member, and the bridge subscription. Keep USAGE_SNAPSHOT, which already carries the per-agent breakdown, so no live data is lost. * refactor(prompter): remove the legacy local-LLM HTTP endpoints The panel uses only the live SDK-intake path (/prompter/live/*); the legacy /prompter/chat, /draft and /sessions/* endpoints — backed by the local Ollama LLM with hardcoded prompts — had no remaining caller. Remove the router, its mount in app.py, and its integration test. The live router and the shared draft-confirmation service are untouched. * refactor(prompter): drop the dead legacy local-LLM service + schemas With the legacy HTTP endpoints gone, the local-LLM chat/draft/session methods, their prompt constants, the ConfirmOverrides/TurnResult dataclasses, and the entire prompter schema module had no production caller (only their own tests). Remove them, keeping the live-intake path: create_task_from_draft / confirm_live_draft, the enum/priority/team coercion, and the pure description/readiness helpers. * refactor(agents): stop granting the Task sub-agent tool to roles Every agent role was granted the built-in Task tool, but no role prompt or workflow uses it and there are no custom sub-agent definitions — so a Task call only spawns a context-blind generic sub-agent that burns budget (ToolSearch, the comment's stated use, is MCP-only and not callable in agent containers). Drop Task from all three grant points in lockstep: the --tools spawn flag and both _ROLE_BUILTIN_TOOLS maps (system-prompt + briefing layers), with a regression guard added to each layer's test. --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
"""
|
|
Usage Event Publisher
|
|
|
|
Helper for publishing USAGE_SNAPSHOT aggregate events to the StreamEventBus.
|
|
Consumed by the orchestrator token sweep and forwarded to /ws/system WebSocket
|
|
clients via the websocket_bridge.
|
|
|
|
USAGE_SNAPSHOT is an aggregate, published at most once per sweep cycle.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from datetime import UTC, datetime
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
if TYPE_CHECKING:
|
|
from roboco.events.stream_bus import StreamEventBus
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class UsageSnapshot:
|
|
"""Aggregate token/cost totals carried by a USAGE_SNAPSHOT event.
|
|
|
|
``totals`` is ``{"input_tokens": int, "output_tokens": int}``; ``by_agent``
|
|
is the per-agent breakdown (each item carries ``agent_id``, token counts,
|
|
``model`` and ``cost_estimate``).
|
|
"""
|
|
|
|
period: str
|
|
totals: dict[str, int]
|
|
cost_estimate: float
|
|
by_agent: list[dict[str, Any]]
|
|
timestamp: datetime | None = None
|
|
|
|
def event_data(self) -> dict[str, Any]:
|
|
"""Render the event payload, stamping ``timestamp`` if not supplied."""
|
|
return {
|
|
"period": self.period,
|
|
"totals": self.totals,
|
|
"cost_estimate": self.cost_estimate,
|
|
"by_agent": self.by_agent,
|
|
"timestamp": (self.timestamp or datetime.now(UTC)).isoformat(),
|
|
}
|
|
|
|
|
|
async def publish_usage_snapshot(bus: StreamEventBus, snapshot: UsageSnapshot) -> None:
|
|
"""Publish a USAGE_SNAPSHOT aggregate event (no throttle)."""
|
|
from roboco.models.events import Event, EventType # lazy — avoids circular import
|
|
|
|
await bus.publish(Event(type=EventType.USAGE_SNAPSHOT, data=snapshot.event_data()))
|