The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(agent/turn): AST-neutral packing of multi-line f-string literals
Teknium1a025a4cc607
diff --git a/agent/turn_api_call.py b/agent/turn_api_call.pyindex b6a2e05f19e..0aa35192899 100644--- a/agent/turn_api_call.py+++ b/agent/turn_api_call.py@@ -226,8 +226,7 @@ def nous_rate_limit_guard(_nous_remaining = nous_rate_limit_remaining()if _nous_remaining is not None and _nous_remaining > 0:_nous_msg = (- f"Nous Portal rate limit active — "- f"resets in {_fmt_nous_remaining(_nous_remaining)}."+ f"Nous Portal rate limit active — resets in {_fmt_nous_remaining(_nous_remaining)}.")agent._buffer_vprint(f"⏳ {_nous_msg} Trying fallback...")agent._buffer_status(f"⏳ {_nous_msg}")diff --git a/agent/turn_empty_response.py b/agent/turn_empty_response.pyindex a840cc2f68b..d018f4d4a17 100644--- a/agent/turn_empty_response.py+++ b/agent/turn_empty_response.py@@ -72,9 +72,7 @@ def _retry_empty(if budget < _empty_guard.DEFAULT_EMPTY_RETRY_BUDGET else "")agent._buffer_status(- f"⚠️ Empty response from model — retrying "- f"({n}/{budget}) "- f"in {wait_time:.0f}s{_budget_note}"+ f"⚠️ Empty response from model — retrying ({n}/{budget}) in {wait_time:.0f}s{_budget_note}")_interrupted = interruptible_backoff_sleep(agent, wait_time, None,@@ -83,8 +81,7 @@ def _retry_empty(api_call_count=api_call_count,abort_message="Interrupt detected during empty-response retry wait, aborting.",interrupt_text=(- f"Operation interrupted: retrying empty response from model "- f"(retry {n}/{budget})."+ f"Operation interrupted: retrying empty response from model (retry {n}/{budget})."),activity_label=f"empty response retry backoff ({n}/{budget})",)@@ -100,8 +97,7 @@ def _terminal_empty(agent: Any, assistant_message: Any, finish_reason: str, mess_streak_cost = _empty_guard.streak_cost_usd(agent)if _streak_cost is not None:agent._buffer_status(- f"ℹ️ Estimated cost of these empty attempts: "- f"~${_streak_cost:.2f} (input tokens are billed "+ f"ℹ️ Estimated cost of these empty attempts: ~${_streak_cost:.2f} (input tokens are billed "f"per attempt even when no answer is produced)")agent._flush_status_buffer()@@ -235,8 +231,7 @@ def recover_empty_response(agent._thinking_prefill_retries,)agent._buffer_status(- f"↻ Thinking-only response — prefilling to continue "- f"({agent._thinking_prefill_retries}/2)"+ f"↻ Thinking-only response — prefilling to continue ({agent._thinking_prefill_retries}/2)")interim_msg = agent._build_assistant_message(assistant_message, "incomplete")interim_msg["_thinking_prefill"] = Truediff --git a/agent/turn_overflow.py b/agent/turn_overflow.pyindex 1e059194c76..dca76b10a46 100644--- a/agent/turn_overflow.py+++ b/agent/turn_overflow.py@@ -272,10 +272,8 @@ def _clamp_output_cap(st: _Recovery, _retry: TurnRetryState, available_out: int,safe_out = max(1, available_out - 64)agent._ephemeral_max_output_tokens = safe_outagent._buffer_vprint(- f"⚠️ Output cap too large for current prompt — "- f"retrying with max_tokens={safe_out:,} "- f"(provider_available={available_out:,}, "- f"estimated_request_tokens={request_input_estimate:,}; "+ f"⚠️ Output cap too large for current prompt — retrying with max_tokens={safe_out:,} "+ f"(provider_available={available_out:,}, estimated_request_tokens={request_input_estimate:,}; "f"context_length unchanged at {old_ctx:,})")# Still count against compression_attempts so a recurring error can't loop forever.diff --git a/agent/turn_truncation.py b/agent/turn_truncation.pyindex 38ff9a7b90f..8dd7ba548c3 100644--- a/agent/turn_truncation.py+++ b/agent/turn_truncation.py@@ -164,8 +164,7 @@ def _content_filter_fallback(st: _Trunc, _retry: TurnRetryState) -> Optional[Tru):return Noneagent._vprint(- f"{agent.log_prefix}🛡️ Content filter terminated "- f"stream — activating fallback provider...",+ f"{agent.log_prefix}🛡️ Content filter terminated stream — activating fallback provider...",force=True,)agent._emit_status("Content filter terminated stream; switching to fallback...")@@ -187,8 +186,7 @@ def _content_filter_fallback(st: _Trunc, _retry: TurnRetryState) -> Optional[Tru_retry.restart_with_rebuilt_messages = Truereturn st.done("break")agent._vprint(- f"{agent.log_prefix}⚠️ No fallback provider "- f"configured — retrying with same provider "+ f"{agent.log_prefix}⚠️ No fallback provider configured — retrying with same provider "f"(may re-hit filter)...",force=True,)@@ -221,9 +219,7 @@ def _continue_text(st: _Trunc, _retry: TurnRetryState, assistant_message: Any) -if st.is_stub and _dropped_tools:agent._vprint(f"{agent.log_prefix}↻ Stream interrupted mid "- f"tool-call ({', '.join(_dropped_tools[:3])}) — requesting "- f"chunked retry "- f"({n}/4)..."+ f"tool-call ({', '.join(_dropped_tools[:3])}) — requesting chunked retry ({n}/4)...")elif st.is_stub:agent._vprint(f"{agent.log_prefix}↻ Stream interrupted — requesting continuation ({n}/4)...")@@ -241,8 +237,7 @@ def _continue_text(st: _Trunc, _retry: TurnRetryState, assistant_message: Any) -# The one-shot reasoning-off override must not leak into the next turn.agent._ephemeral_reasoning_off = Falseagent._vprint(- f"{agent.log_prefix}⚠️ Response still truncated "- f"after {n} continuation attempts — "+ f"{agent.log_prefix}⚠️ Response still truncated after {n} continuation attempts — "+ ("keeping the partial response received so far." if partial_responseelse "no visible text was produced."),force=True,