GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — observable-agent-loop-solution/src/cli.py at main · Kunal-CodeLab/observable-agent-loop-solution Expand file tree/ Copy pathcli.pyMore file actions 106 lines (85 loc) · 4.81 KB / Copy pathcli.pyFile metadata and controls106 lines (85 loc) · 4.81 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 """ CLI output formatter and terminal renderer for Observable Agent Loop traces. """ from __future__ import annotations import json import sys from typing import Any, Optional from src.types import ExecutionTrace, LoopStatus, ToolStatus class Colors: HEADER = "\033[95m" BLUE = "\033[94m" CYAN = "\033[96m" GREEN = "\033[92m" YELLOW = "\033[93m" RED = "\033[91m" BOLD = "\033[1m" DIM = "\033[2m" RESET = "\033[0m" def print_banner(): banner = f"""{Colors.CYAN}{Colors.BOLD} ======================================================================== CAYGNUS OBSERVABLE AGENT LOOP - INCIDENT INVESTIGATOR HARNESS ========================================================================{Colors.RESET}""" print(banner) def render_trace(trace: ExecutionTrace, output_json: bool = False): """Renders execution trace with distinct operational steps, evidence, and conclusions.""" if output_json: print(json.dumps(trace.to_summary_dict(), indent=2)) return status_color = Colors.GREEN if trace.loop_status == LoopStatus.COMPLETED else ( Colors.YELLOW if trace.loop_status == LoopStatus.MAX_STEPS_EXCEEDED else Colors.RED ) print(f"\n{Colors.BOLD}--- EXECUTION TRACE HEADER ---{Colors.RESET}") print(f" {Colors.BOLD}Session ID:{Colors.RESET} {trace.session_id}") print(f" {Colors.BOLD}Objective:{Colors.RESET} {trace.objective}") print(f" {Colors.BOLD}Status:{Colors.RESET} {status_color}{trace.loop_status.value.upper()}{Colors.RESET}") print(f" {Colors.BOLD}Total Steps:{Colors.RESET} {trace.total_steps} / {trace.max_steps_allowed} max") print(f" {Colors.BOLD}Duration:{Colors.RESET} {trace.total_duration_ms:.2f} ms") print(f"{Colors.DIM}{'-' * 72}{Colors.RESET}") print(f"\n{Colors.BOLD}{Colors.CYAN}--- STEP-BY-STEP OPERATIONAL TIMELINE ---{Colors.RESET}") for step in trace.steps: print(f"\n{Colors.BOLD}[Step {step.step_number}]{Colors.RESET} {Colors.DIM}({step.duration_ms:.1f}ms) @ {step.timestamp}{Colors.RESET}") if step.model_decision: decision = step.model_decision if decision.explanation: print(f" {Colors.DIM}Rationale:{Colors.RESET} {decision.explanation}") if decision.tool_call: tc = decision.tool_call print(f" {Colors.BLUE}{Colors.BOLD}Tool Call:{Colors.RESET} {tc.tool_name}") print(f" {Colors.DIM}Arguments:{Colors.RESET} {json.dumps(tc.arguments, indent=4)}") if step.tool_result: tr = step.tool_result if tr.is_success: print(f" {Colors.GREEN}{Colors.BOLD}Tool Status:{Colors.RESET} SUCCESS ({tr.duration_ms:.1f}ms)") formatted_data = json.dumps(tr.data, indent=4) if isinstance(tr.data, (dict, list)) else str(tr.data) # truncate if overly long if len(formatted_data) > 400: formatted_data = formatted_data[:400] + f"\n {Colors.DIM}... [truncated for display]{Colors.RESET}" print(f" {Colors.DIM}Data:{Colors.RESET}\n{formatted_data}") else: print(f" {Colors.RED}{Colors.BOLD}Tool Status: ERROR{Colors.RESET} ({tr.duration_ms:.1f}ms)") print(f" {Colors.RED}Error Message:{Colors.RESET} {tr.error_message}") print(f"\n{Colors.DIM}{'=' * 72}{Colors.RESET}") # Render Structured Final Output (AC6: Decoupling Evidence from Inferences) if trace.final_response: resp = trace.final_response print(f"\n{Colors.BOLD}{Colors.GREEN}================ FINAL INVESTIGATION REPORT ================{Colors.RESET}") print(f"\n{Colors.BOLD}EXECUTIVE SUMMARY:{Colors.RESET}") print(f" {resp.summary}") print(f"\n{Colors.BOLD}GROUNDED TOOL EVIDENCE (Objective Facts):{Colors.RESET}") if resp.evidence_collected: for idx, ev in enumerate(resp.evidence_collected, 1): print(f" {Colors.CYAN}[{idx}] [{ev.source_tool}]{Colors.RESET} {ev.fact}") if ev.timestamp: print(f" {Colors.DIM}Timestamp: {ev.timestamp}{Colors.RESET}") else: print(f" {Colors.DIM}(No empirical evidence recorded){Colors.RESET}") print(f"\n{Colors.BOLD}ROOT CAUSE INFERENCE (Agent Analysis):{Colors.RESET}") for item in resp.root_cause_analysis: print(f" {Colors.YELLOW}* {item}{Colors.RESET}") print(f"\n{Colors.BOLD}REMEDIATION RECOMMENDATIONS:{Colors.RESET}") for item in resp.recommendations: print(f" {Colors.GREEN}* {item}{Colors.RESET}") print(f"\n{Colors.BOLD}Confidence:{Colors.RESET} {resp.confidence_level} | {Colors.BOLD}Final Loop Status:{Colors.RESET} {status_color}{resp.status.value}{Colors.RESET}") print(f"{Colors.GREEN}{'=' * 60}{Colors.RESET}\n") |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |