The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(agent): reuse auxiliary_client message helpers in _response_refusal_text
kshitijk4poora8f87c397a5d
diff --git a/agent/context_compressor.py b/agent/context_compressor.pyindex 3664a70c1df..09e887dc290 100644--- a/agent/context_compressor.py+++ b/agent/context_compressor.py@@ -17,7 +17,9 @@ from typing import Any, Dict, List, Optional, Tuplefrom agent.image_eviction_policy import outbound_image_retire_countfrom agent.auxiliary_client import (AuxiliaryExplicitCancellation,+ _coerce_llm_message,_is_connection_error,+ _message_field,aux_interrupt_protection,call_llm,extract_content_or_reasoning,@@ -190,12 +192,10 @@ def _response_refusal_text(response: Any) -> str:OpenAI-style structured-output refusals put the refusal here and leave ``content`` as filler orempty, so the prose detector never sees it."""- choices = (response.get("choices") if isinstance(response, dict) else getattr(response, "choices", None)) or []- if not choices:+ message = _coerce_llm_message(response)+ if message is None or isinstance(message, str):return ""- first = choices[0]- message = first.get("message") if isinstance(first, dict) else getattr(first, "message", None)- refusal = message.get("refusal") if isinstance(message, dict) else getattr(message, "refusal", None)+ refusal = _message_field(message, "refusal")if isinstance(refusal, dict):refusal = refusal.get("message") or refusal.get("reason") or refusal.get("text")return refusal.strip() if isinstance(refusal, str) else ""