mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-17 18:25:42 +02:00
[eric] agents: drop orphaned compaction comment block (code moved in refactor) + tighten a 15-line narrow-wrapped comment to 3
This commit is contained in:
@@ -50,27 +50,6 @@ class AgentManager(SessionLifecycle, SessionPersistence, Messaging, SessionContr
|
||||
self.cancel_events: Dict[str, asyncio.Event] = {}
|
||||
|
||||
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Compaction & token guard (Phase 2)
|
||||
#
|
||||
# Triggered by *live* context-usage ratio, not turn count. The signal
|
||||
# is the same `ctx_used_pct` we already broadcast to the UI on every
|
||||
# turn: input_tokens / context_window. Three escalating thresholds:
|
||||
# - compact_threshold_pct (default 0.65): summarize stale tool_results
|
||||
# and old user/assistant pairs before the next query() call
|
||||
# - context_soft_cap_pct (default 0.90): pre-send hard guard. After
|
||||
# compaction, if still over, LRU-trim active_mcps
|
||||
# - >= 1.0 hits the proxy/Anthropic 200K ceiling, friendly card
|
||||
# surfaces from the catch-all
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@typechecked
|
||||
async def run_agent_loop(self, session_id: str, prompt: str, images: Optional[List] = None, context_paths: Optional[List] = None, forced_tools: Optional[List[str]] = None, attached_skills: Optional[List] = None, fork_session: bool = False, selected_browser_ids: Optional[List[str]] = None, selected_app_output_ids: Optional[List[str]] = None, selected_setting_ids: Optional[List[str]] = None):
|
||||
"""Run the Claude Agent SDK query loop for a session."""
|
||||
|
||||
@@ -80,21 +80,9 @@ async def handle_stream_event(
|
||||
tool_msg_id = uuid4().hex
|
||||
turn.stream_tool_msg_ids_ordered.append(tool_msg_id)
|
||||
turn.stream_block_index_map[index] = tool_msg_id
|
||||
# Stream-level tool count for the
|
||||
# consolidated thinking pill. The
|
||||
# AssistantMessage path (further down)
|
||||
# ALSO increments turn.tool_count when
|
||||
# ToolUseBlocks fully arrive, but for
|
||||
# OpenAI/Gemini through 9Router the
|
||||
# AssistantMessage envelope is sometimes
|
||||
# incomplete, so this stream-level count
|
||||
# is what guarantees the "N tools used"
|
||||
# segment renders cross-provider. To
|
||||
# avoid double-counting we DON'T also
|
||||
# increment on AssistantMessage when
|
||||
# this code path already fired, see
|
||||
# the dedupe at the AssistantMessage
|
||||
# block below.
|
||||
# Stream-level tool count for the thinking pill. OpenAI/Gemini-through-9Router
|
||||
# AssistantMessage envelopes are sometimes incomplete, so this stream count guarantees
|
||||
# "N tools used" renders cross-provider; the AssistantMessage path dedupes against it.
|
||||
turn.tool_count += 1
|
||||
await ws_manager.send_to_session(session_id, "agent:stream_start", {
|
||||
"session_id": session_id,
|
||||
|
||||
Reference in New Issue
Block a user