# session-health-quick-util — Fast Terminal-State Classifier

**Agent file:** [`agents/session-health-quick-util.md`](../../../../agents/session-health-quick-util.md)

**Invoked by:** `session-health-util` (Tier 1 of the two-tier health pipeline)

**Hidden:** Yes (internal infrastructure, not user-facing)

## Purpose

Determines whether a session's terminal state is **obviously** `finished` or **obviously** `errored` based only on the last 3 text-only messages. Uses the `auto-agents-system` skill to understand what each agent type is supposed to achieve, enabling contextually-aware classification.

The default verdict is **`escalate`** — this agent only commits to `finished` or `errored` when the evidence is unambiguous (≥95% confidence). Any doubt escalates to the full evaluator.

## Design Principle

This agent exists to eliminate the easy cases cheaply. It is not trying to classify everything — it is identifying what is unambiguously clear from the final messages alone. A `commit staged changes` session whose last message says "Committed successfully" is obviously finished. An agent whose last message says "I cannot proceed without human intervention" is obviously errored. Everything else escalates.

## Input (prompt from session-health-util)

| Field | Description |
|-------|-------------|
| `session_id` | Session ID |
| `title` | Full session title |
| `tag` | Extracted tag or null |
| `status` | `busy` or `idle` |
| `last_active_ms` | Epoch ms of last activity |
| `collected_at_ms` | Epoch ms when snapshot was taken |
| `idle_threshold_minutes` | Stuck threshold |
| `messages` | JSON array of last 3 messages (text-only, pre-fetched by coordinator) |

## Output

```json
{
  "verdict": "finished" | "errored" | "escalate",
  "reason": "<one sentence explaining the verdict>"
}
```

## Escalation Rules

**Always escalates (returns `escalate`) when:**
- Session `status` is `busy` (timing and tool analysis needed)
- Session tag ends in `-SUP` (supervisors never finish)
- Messages are empty, tool-call-only, or ambiguous
- Last message is a user message (agent may not have responded)
- Confidence is anything less than ~95%

**Returns `finished` only when ALL are true:**
- `status == "idle"`
- Last assistant message contains an unambiguous completion signal appropriate for the agent type
- No errors anywhere in the 3 messages
- Session type can finish (not a supervisor)

**Returns `errored` only when ALL are true:**
- Last message contains an explicit, unrecoverable failure statement
- Agent has stopped (not retrying)
- No workaround was found or attempted

## Skill loaded

`auto-agents-system` — essential for knowing what completion looks like for each agent type and which session types (supervisors) should never be classified as finished.
