Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
refactor(agent): derive recovery count from segments
chengyongru3cc5a98d9f9e
diff --git a/nanobot/agent/runner.py b/nanobot/agent/runner.pyindex a898936e4..18e93aad8 100644--- a/nanobot/agent/runner.py+++ b/nanobot/agent/runner.py@@ -392,7 +392,6 @@ class AgentRunner:# Per-turn throttle for repeated attempts against the same outside target.workspace_violation_counts: dict[str, int] = {}empty_content_retries = 0- length_recovery_count = 0# Segments from one uninterrupted length-recovery chain. Tool work or# injected user input starts a new logical answer and clears the chain.length_recovery_parts: list[str] = []@@ -520,7 +519,6 @@ class AgentRunner:)if should_continue:had_injections = True- length_recovery_count = 0length_recovery_parts.clear()continuebreak@@ -536,7 +534,6 @@ class AgentRunner:},)empty_content_retries = 0- length_recovery_count = 0length_recovery_parts.clear()# Checkpoint 1: drain injections after tools, before next LLM call_drained, injection_cycles = await self._try_drain_injections(@@ -590,8 +587,7 @@ class AgentRunner:clean = hook.finalize_content(context, response.content)if response.finish_reason == "length" and not is_blank_text(clean):- length_recovery_count += 1- if length_recovery_count <= _MAX_LENGTH_RECOVERIES:+ if len(length_recovery_parts) < _MAX_LENGTH_RECOVERIES:length_recovery_parts.append(_restore_outer_whitespace(clean, original_content))@@ -599,7 +595,7 @@ class AgentRunner:"Output truncated on turn {} for {} ({}/{}); continuing",iteration,spec.session_key or "default",- length_recovery_count,+ len(length_recovery_parts),_MAX_LENGTH_RECOVERIES,)if hook.wants_streaming():@@ -637,7 +633,6 @@ class AgentRunner:await hook.on_stream_end(context, resuming=should_continue)if should_continue:- length_recovery_count = 0length_recovery_parts.clear()await hook.after_iteration(context)continue@@ -660,7 +655,6 @@ class AgentRunner:)if should_continue:had_injections = True- length_recovery_count = 0length_recovery_parts.clear()continuebreak@@ -679,7 +673,6 @@ class AgentRunner:)if should_continue:had_injections = True- length_recovery_count = 0length_recovery_parts.clear()continuebreak