Newer
Older
navi-1 / navi / core / agent_run_context.py
@Eugene Sukhodolskiy Eugene Sukhodolskiy on 16 May 705 bytes Step 3: Extract AntiStallMonitor from run_stream()
"""Turn-level execution state for the Agent streaming loop."""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    pass


@dataclass
class AgentTurnContext:
    """Mutable container for state that lives across iterations of a single run_stream() turn.

    Extracting these variables from run_stream() makes the method readable and lets
    services (AntiStallMonitor, Compressor) receive the turn state explicitly instead
    of returning tuples.
    """

    turn_start: float
    tool_call_count: int = 0
    turn_tokens: int = 0
    subagent_tokens: int = 0
    injected_fact_ids: set[str] = field(default_factory=set)