Quickstart
A 3-minute hands-on walkthrough: supervise a failing Python agent, inspect traces, and generate your first post-mortem.
In this practical 3-minute tutorial, you will simulate a failing agent with an unhandled database retry loop, supervise it with lastsignal run, and generate an evidence-grounded post-mortem report.
1. Create a Failing Agent Script
Save the following sample code as agent.py. It emits structured JSONL telemetry and simulates a fatal tool outage:
1import json2import sys3import time45def log_event(event_type, **kwargs):6 payload = {"timestamp": time.time(), "event_type": event_type, **kwargs}7 print(f"__LS_EVENT__{json.dumps(payload)}", flush=True)89print("Starting agent execution...", flush=True)10log_event("agent_start", trace_id="trace_quickstart_01")1112# Simulate tool invocation with repeated failures13for attempt in range(1, 4):14 print(f"[Agent] Invoking database_query (attempt {attempt})...", flush=True)15 log_event("tool_call", operation="database_query", attempt=attempt)16 time.sleep(0.5)17 log_event("tool_result", operation="database_query", status="failed", error_message="Timeout connecting to replica")18 log_event("retry", operation="database_query", attempt=attempt)1920# Fatal crash: agent exhausts retries and aborts21print("CRITICAL: Unrecoverable database failure. Aborting.", file=sys.stderr, flush=True)22log_event("process_error", error_message="MaxRetriesExceeded: replica pool dead")23sys.exit(1)
2. Supervise with Last Signal
Wrap your agent execution with lastsignal run --. The supervisor spawns the agent as a supervised subprocess, captures unbuffered stdout/stderr, and saves raw telemetry:
3. Analyze Deterministic Evidence
Run lastsignal analyze without arguments. It automatically detects the most recent failed trace in your current workspace and runs all deterministic failure rules:
4. Review the Forensic Post-Mortem
Generate a GitHub-ready Markdown post-mortem with lastsignal report: