Skip to content

0.4.0: supervision diagnostics (partial summaries, tool output window, fleet git, creation reuse) - #11

Merged
yoch merged 2 commits into
mainfrom
feat/0.4.0-supervision-diagnostics
Oct 9, 2026
Merged

yoch merged 2 commits into
mainfrom
feat/0.4.0-supervision-diagnostics

Conversation

@yoch

@yoch yoch commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Implements the four improvement tracks in TODO.md, from a real supervision session (an autoqueue supervisor, *_job.py scripts, eight runners). Each track is a server-side means; no agent-side convention is prescribed.

A — Error diagnosis

  • activity.last_events: the last ~10 events observed during the read, produced by the walk the summary already pays for.
  • A stream ending on an error event now returns the partial summary with stream_error: true and complete: false (the error event stays in last_events), never cached — previously the call returned activity_error: UPSTREAM and no summary.
  • The last tool call of the summary is clipped wider (2000 chars), applied in _simplify() during the walk.

B — Tool outputs

  • cursor_read_run_events(tool_output_limit=…) (default 500, max 4000) on both modes.
  • Tool args/results are clipped head + tail with an explicit …[clipped]… marker, total within the limit; assistant/thinking text is unchanged.
  • tool_args_omitted / tool_result_omitted report a field Cursor itself omitted upstream. Verified live on 2026-10-09: an 8 MB terminal output produced truncated: {result: true} with result absent (one-off paid run, 17.3 s, 7.62 cents, agent deleted); the captured payload is frozen in the regression test and in docs/api-contract.md.
  • Explicit global cap on rendered tool text; last_event_id stays on the last event actually returned, so a resume returns the following events.

D — Fleet state

  • git (with scope=agent_current_state) added to cursor_list_runs items and cursor_supervise rows, no extra API calls.

C — Creation recovery

  • cursor_create_agent(on_conflict="reuse"), with a caller-supplied agent_id: on 409 agent_id_conflict, the existing agent is returned with reused: true and its observed latest_run_id (run_id/run_status absent). No run is sent; the prompt is not applied. A failed re-read stays an AGENT_ID_CONFLICT error saying the same call can be retried.

Checks

  • uv run pytest: 133 passed (+8).
  • uvx ruff@0.16.10 check src tests scripts: clean.
  • Wheel 0.4.0 built, installed in a clean venv, scripts/wheel_smoke.py OK.
  • Docs: README, AGENT_GUIDE.md migration 0.3 → 0.4, docs/api-contract.md, docs/verification.md. Also included: AGENTS.md (repo guidance for future agent sessions) and TODO.md (the contract of record).

__version__ is bumped to 0.4.0; the release runs when a v0.4.0 tag is pushed.

yoch added 2 commits October 9, 2026 14:01
…eation reuse

- Activity: last observed events, partial summary with stream_error on a stream
  error (never cached), wider last-tool-call clip.
- Run lists and supervise rows expose git (the agent's current pushed state).
- cursor_read_run_events(tool_output_limit): head+tail clip, upstream omitted
  flags (verified live 2026-10-09), global tool-text cap with resumable cursor.
- cursor_create_agent(on_conflict=reuse): recover the existing agent on 409.
- Docs: README, AGENT_GUIDE migration 0.3 -> 0.4, API contract, verification.
- 133 tests; version 0.4.0.
The cap only applied to the incremental read: cursor_read_run_events(tail=…,
tool_output_limit=4000) could return about 1.6 M chars of tool text (audit of
7991f4e, 50 tool calls: 392 000 chars returned against a 256 000 cap).

- tail_view() now trims the returned suffix from its oldest side until the
  rendered tool text fits TOOL_TEXT_TOTAL_MAX_CHARS, keeping the newest events
  and the last_event_id coherent; truncated is set when the window was trimmed.
- The replay walk is unchanged: it always runs to its usual stop criterion, so
  tail still reaches the recent events.
- Shared tool_text_cost() helper, used by both read paths.
- Regression test on the audited scenario: 50 tool calls clipped at 4000 per
  field, production cap: 32 calls kept, 256 000 chars, newest kept, truncated
  true. 134 tests.
@yoch

yoch commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

P2 fixed in bdcc341 (Bound the tail window by the global tool-text cap).

  • tail_view() now trims the returned suffix from its oldest side until the rendered tool text fits TOOL_TEXT_TOTAL_MAX_CHARS, keeping the newest events and last_event_id coherent; truncated is set when the window was trimmed.
  • The replay walk is unchanged: it still runs to its usual stop criterion, so tail keeps reaching the recent events.
  • tool_text_cost() is shared by both read paths.
  • Regression test on the audited scenario (50 tool calls, args and result clipped at 4000 each, production cap): 32 calls kept, 256 000 chars, newest kept, truncated: true, scanned_events: 52.
  • Docs updated (tool docstring, README, migration guide, TODO).

134 tests pass; ruff clean. CI re-running on the new HEAD.

@yoch
yoch merged commit a56400f into main Oct 9, 2026
2 checks passed
@yoch
yoch deleted the feat/0.4.0-supervision-diagnostics branch October 9, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant