xml-pipeline/xml_pipeline/primitives/__init__.py
dullfig e6697f0ea2 Add BudgetWarning system alerts for token budget thresholds
- Create BudgetWarning primitive payload (75%, 90%, 95% thresholds)
- Add threshold tracking to ThreadBudget with triggered_thresholds set
- Change consume() to return (budget, crossed_thresholds) tuple
- Wire warning injection in LLM router when thresholds crossed
- Add 15 new tests for threshold detection and warning injection

Agents now receive BudgetWarning messages when approaching their token limit,
allowing them to design contingencies (summarize, escalate, save state).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 21:41:34 -08:00

66 lines
1.5 KiB
Python

"""
System primitives — Core message types handled by the organism itself.
These are not user-defined listeners but system-level messages that
establish context, handle errors, and manage the organism lifecycle.
"""
from xml_pipeline.primitives.boot import Boot, handle_boot
from xml_pipeline.primitives.todo import (
TodoUntil,
TodoComplete,
TodoRegistered,
TodoClosed,
handle_todo_until,
handle_todo_complete,
)
from xml_pipeline.primitives.text_input import TextInput, TextOutput
from xml_pipeline.primitives.sequence import (
SequenceStart,
SequenceComplete,
SequenceError,
handle_sequence_start,
)
from xml_pipeline.primitives.buffer import (
BufferStart,
BufferItem,
BufferComplete,
BufferDispatched,
BufferError,
handle_buffer_start,
)
from xml_pipeline.primitives.budget_warning import (
BudgetWarning,
DEFAULT_THRESHOLDS,
)
__all__ = [
# Boot
"Boot",
"handle_boot",
# Todo
"TodoUntil",
"TodoComplete",
"TodoRegistered",
"TodoClosed",
"handle_todo_until",
"handle_todo_complete",
# Text I/O
"TextInput",
"TextOutput",
# Sequence orchestration
"SequenceStart",
"SequenceComplete",
"SequenceError",
"handle_sequence_start",
# Buffer orchestration
"BufferStart",
"BufferItem",
"BufferComplete",
"BufferDispatched",
"BufferError",
"handle_buffer_start",
# Budget warnings
"BudgetWarning",
"DEFAULT_THRESHOLDS",
]