@@ -107,17 +107,33 @@ def detect_harmony_agent(agent: Any) -> bool:
107107
108108 # Strategy 3: Check model name/id for gpt-oss or harmony
109109 model_indicators = []
110+
111+ # Check direct string attributes on agent
112+ for attr in ["model" , "model_id" , "model_name" ]:
113+ if hasattr (agent , attr ):
114+ model_value = getattr (agent , attr )
115+ if model_value and isinstance (model_value , str ):
116+ model_indicators .append (model_value .lower ())
117+ logger .debug (f"Found model string on agent.{ attr } : { model_value } " )
118+
119+ # Check nested attributes on agent.model object
110120 if hasattr (agent , "model" ):
111121 model = agent .model
112- for attr in ["model_id" , "model" , "model_name" , "name" ]:
113- if hasattr (model , attr ):
114- model_value = getattr (model , attr )
115- if model_value :
116- model_indicators .append (str (model_value ).lower ())
122+ # If model itself is a string, we already captured it above
123+ if not isinstance (model , str ):
124+ for attr in ["model_id" , "model" , "model_name" , "name" , "id" ]:
125+ if hasattr (model , attr ):
126+ model_value = getattr (model , attr )
127+ if model_value :
128+ model_indicators .append (str (model_value ).lower ())
129+ logger .debug (
130+ f"Found model on agent.model.{ attr } : { model_value } "
131+ )
117132
133+ # Check if any indicator contains gpt-oss or harmony
118134 for indicator in model_indicators :
119135 if "gpt-oss" in indicator or "harmony" in indicator :
120- logger .info (f"Agent model contains harmony indicator: { indicator } " )
136+ logger .info (f"✓ Agent model contains harmony indicator: { indicator } " )
121137 return True
122138
123139 # Strategy 4: Check agent class name
@@ -132,6 +148,13 @@ def detect_harmony_agent(agent: Any) -> bool:
132148 logger .info ("Agent has harmony-specific methods" )
133149 return True
134150
151+ # No harmony indicators found
152+ logger .debug (
153+ f"No harmony indicators found. Checked: "
154+ f"attributes (uses_harmony, harmony_encoding), "
155+ f"model indicators: { model_indicators } , "
156+ f"class: { agent .__class__ .__name__ } "
157+ )
135158 return False
136159
137160 def process_response (
0 commit comments