(output_dir: str)
| 117 | |
| 118 | |
| 119 | def _write_per_agent_latency(output_dir: str) -> None: |
| 120 | latency_path = Path(output_dir) / "Latency.json" |
| 121 | if not latency_path.exists(): |
| 122 | logger.warning("Latency.json not found at {}", str(latency_path)) |
| 123 | return |
| 124 | try: |
| 125 | with open(latency_path, "r", encoding="utf-8") as f: |
| 126 | records = json.load(f) |
| 127 | except Exception as e: |
| 128 | logger.warning("Could not read Latency.json: {}", e) |
| 129 | return |
| 130 | by_agent: Dict[str, List[Dict[str, Any]]] = {} |
| 131 | for rec in records if isinstance(records, list) else []: |
| 132 | agent_id = rec.get("agent_id") or "unknown" |
| 133 | by_agent.setdefault(agent_id, []).append(rec) |
| 134 | out_dir = Path(output_dir) / "agent_latency" |
| 135 | out_dir.mkdir(parents=True, exist_ok=True) |
| 136 | for agent_id, items in by_agent.items(): |
| 137 | agent_file = out_dir / f"agent_{agent_id}.json" |
| 138 | with open(agent_file, "w", encoding="utf-8") as f: |
| 139 | json.dump(items, f, ensure_ascii=False, indent=2) |
| 140 | combined = out_dir / "PerAgentLatency.json" |
| 141 | with open(combined, "w", encoding="utf-8") as f: |
| 142 | json.dump(by_agent, f, ensure_ascii=False, indent=2) |
| 143 | |
| 144 | async def main(): |
| 145 | args = parse_args() |
no test coverage detected