fix: tolerate test doubles without model attr
Use getattr() when returning model metadata from GatewayRunner._run_agent so fake agents and minimal stubs without a model attribute do not break unrelated gateway flows while preserving the session-model backfill behavior.
This commit is contained in:
parent
8602e61fca
commit
19f4f8970a
1 changed files with 3 additions and 2 deletions
|
|
@ -3577,6 +3577,7 @@ class GatewayRunner:
|
||||||
_agent = agent_holder[0]
|
_agent = agent_holder[0]
|
||||||
if _agent and hasattr(_agent, "context_compressor"):
|
if _agent and hasattr(_agent, "context_compressor"):
|
||||||
_last_prompt_toks = getattr(_agent.context_compressor, "last_prompt_tokens", 0)
|
_last_prompt_toks = getattr(_agent.context_compressor, "last_prompt_tokens", 0)
|
||||||
|
_resolved_model = getattr(_agent, "model", None) if _agent else None
|
||||||
|
|
||||||
if not final_response:
|
if not final_response:
|
||||||
error_msg = f"⚠️ {result['error']}" if result.get("error") else "(No response generated)"
|
error_msg = f"⚠️ {result['error']}" if result.get("error") else "(No response generated)"
|
||||||
|
|
@ -3587,7 +3588,7 @@ class GatewayRunner:
|
||||||
"tools": tools_holder[0] or [],
|
"tools": tools_holder[0] or [],
|
||||||
"history_offset": len(agent_history),
|
"history_offset": len(agent_history),
|
||||||
"last_prompt_tokens": _last_prompt_toks,
|
"last_prompt_tokens": _last_prompt_toks,
|
||||||
"model": agent_holder[0].model if agent_holder[0] else None,
|
"model": _resolved_model,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Scan tool results for MEDIA:<path> tags that need to be delivered
|
# Scan tool results for MEDIA:<path> tags that need to be delivered
|
||||||
|
|
@ -3650,7 +3651,7 @@ class GatewayRunner:
|
||||||
"tools": tools_holder[0] or [],
|
"tools": tools_holder[0] or [],
|
||||||
"history_offset": len(agent_history),
|
"history_offset": len(agent_history),
|
||||||
"last_prompt_tokens": _last_prompt_toks,
|
"last_prompt_tokens": _last_prompt_toks,
|
||||||
"model": agent_holder[0].model if agent_holder[0] else None,
|
"model": _resolved_model,
|
||||||
"session_id": effective_session_id,
|
"session_id": effective_session_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue