diff --git a/run_agent.py b/run_agent.py index b16738d96..008d4b00e 100644 --- a/run_agent.py +++ b/run_agent.py @@ -7059,6 +7059,15 @@ class AIAgent: finish_reason = response.choices[0].finish_reason if finish_reason == "length": + if not self.compression_enabled: + return { + "final_response": None, + "messages": messages, + "api_calls": api_call_count, + "completed": False, + "partial": True, + "error": "Response truncated due to output length limit", + } self._vprint(f"{self.log_prefix}⚠️ Response truncated (finish_reason='length') - model hit max output tokens", force=True) # ── Detect thinking-budget exhaustion ──────────────