fix(conductor): Apply review suggestions for track 'event_driven_metrics_20260223'

This commit is contained in:
2026-02-23 16:45:34 -05:00
parent eaaf09dc3c
commit 66f728e7a3
4 changed files with 55 additions and 23 deletions

View File

@@ -632,7 +632,15 @@ def _send_gemini(md_content: str, user_message: str, base_dir: str, file_items:
if cached_tokens:
usage["cache_read_input_tokens"] = cached_tokens
events.emit("response_received", payload={"provider": "gemini", "model": _model, "usage": usage, "round": r_idx})
# Fetch cache stats in the background thread to avoid blocking GUI
cache_stats = None
try:
cache_stats = get_gemini_cache_stats()
except Exception:
pass
events.emit("response_received", payload={"provider": "gemini", "model": _model, "usage": usage, "round": r_idx, "cache_stats": cache_stats})
reason = resp.candidates[0].finish_reason.name if resp.candidates and hasattr(resp.candidates[0], "finish_reason") else "STOP"
_append_comms("IN", "response", {"round": r_idx, "stop_reason": reason, "text": txt, "tool_calls": [{"name": c.name, "args": dict(c.args)} for c in calls], "usage": usage})