feat(observability): structured termination reason for every run

Open
#149 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
observability

Research direction

The issue names no files, tests, or entry points. Start by locating the trajectory/result payload and the termination paths that produce it, then define how each proposed reason maps to a terminated run. Done means every terminated run carries a machine-readable termination record in the result artifact, with timeout and backend errors distinguishable.

Written by the indexing model from the issue text.

Description

Problem

When a run ends abnormally, the result payload carries no machine-readable cause. Operators are left doing forensic fingerprinting — e.g. inferring "launch stall" from n_messages == 0 && elapsed ≈ watchdog timeout, or diffing timestamps to separate "gateway rejected the request" from "agent deadlocked internally" from "model stopped making progress".

In batch usage this is the single largest operational cost: for one incident class, roughly half of the debugging time went into merely classifying failures before any actual fixing could start.

Proposal

Every terminated run should emit a structured termination record in the result artifact itself (not only in logs), e.g.:

{
  "finish_reason": "llm_call_timeout",
  "detail": { "last_error": "...", "http_status": 429, "turn": 17 }
}

Suggested enum, minimally:

  • completed — normal finish
  • max_turns / budget_exhausted
  • context_limit_salvaged — see #152
  • llm_call_timeout vs backend_error(code) — these two being distinguishable is the core ask
  • no_progress — loop-break / degeneration interventions
  • aborted — external kill

Design notes:

  • The record belongs on the trajectory/result payload so downstream consumers can filter programmatically.
  • Pairs naturally with a heartbeat/progress event stream (#153): heartbeat covers the run's lifetime, termination reason covers its end.
Dominant language
Python
Stars
4.1k
Forks
94
Avg merge
2d 7h
Merged PRs (30d)
216

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EverMind-AI/Raven

All issues in EverMind-AI/Raven

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.