Update claude_agent_pipe_sandboxed.py

This commit is contained in:
Speedliner 2026-08-07 15:44:42 +02:00 committed by GitHub
parent ee6fc4c3c5
commit 6ac8d3b52c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 0 deletions

View File

@ -994,10 +994,40 @@ async def _handle_event(
)
return
if etype == "rate_limit_event":
info = event.get("rate_limit_info") or {}
status = info.get("status")
line_parts = []
if status == "rejected":
line_parts.append("🛑 API-Limit erreicht")
elif status == "allowed_warning":
line_parts.append("⚠️ API-Limit fast erreicht")
else:
line_parts.append(f" Rate-Limit-Status: {status}")
rl_type = info.get("rateLimitType")
if rl_type:
line_parts.append(f"({rl_type})")
utilization = info.get("utilization")
if utilization is not None:
line_parts.append(f"· {utilization * 100:.0f}% genutzt")
resets_at = info.get("resetsAt")
if resets_at:
import datetime
reset_str = datetime.datetime.fromtimestamp(resets_at).strftime("%H:%M:%S")
line_parts.append(f"· verfügbar wieder ab {reset_str}")
line = " ".join(line_parts)
await emit_status(line, done=(status == "rejected"))
if status in ("allowed_warning", "rejected"):
yield f"\n\n_{line}_\n"
return
if etype == "result":
subtype = event.get("subtype")
if subtype and subtype != "success":
yield f"\n\n_Agent stopped: {subtype}_\n"
api_error_status = event.get("api_error_status")
if api_error_status:
yield f"\n\n**API-Fehler:** `{api_error_status}`\n"
cost = event.get("total_cost_usd")
dur = event.get("duration_ms")
if cost is not None and dur is not None: