Skip to content

Publish context-window, compaction and subagent figures in telemetry #245

Closed

Description

@lbacik

Parent

Agent-side change from the map Agent fleet dashboard: map; the consolidated list is in the resolution of Define the dashboard project. The snapshot shape is decided in Define the telemetry snapshot contract and the command mechanics in Decide the agentctl telemetry command. Terms: Telemetry snapshot and Figure basis in CONTEXT.md; ADR 0006.

What to build

Telemetry shows how full the main context is against the window the CLI actually uses, the compactions so far, and each subagent's context, each tagged with its figure basis.

Acceptance criteria

  • context.main and context.main_peak come from the ledger, with the basis of the ledger reading.
  • context.window and context.auto_compact_threshold come from the SDK's context-usage call, made on the attempt's event loop only at session start and after each compaction (never per turn). Their basis is sdk_assumed, or configured when CLAUDE_CODE_MAX_CONTEXT_TOKENS is set. A failed call yields unavailable with a reason and does not affect the attempt.
  • context.compactions is {count, last: {at, trigger, pre_tokens, post_tokens}} (measured), from compaction boundary events.
  • context.subagents lists {id, type, context, running} (context estimated), running ones first, at most 20 entries. Subagent start and finish are tracked so running is accurate.
  • Snapshot trimming over the size cap drops subagent entries after recent events.
  • Tests: window basis with and without the override; a compaction updates the count and the last compaction and triggers a new context-usage reading; subagent ordering and the 20-entry limit.

Blocked by

Activity

  1. added
    ready-for-agentFully specified implementation issue ready for an unattended agent
    on Oct 14, 2026
  2. added a commit that references this issue on Oct 14, 2026
  3. self-assigned this
    on Oct 14, 2026
  4. lbacik commented on Oct 14, 2026

    @lbacik
    OwnerAuthor

    Agent Attempt Result: handoff

    Branch: agent/issue-245
    PR: none
    Handoff note commit: 10d3a0be7087e12b67db60f96debd686b095d605

    Evidence

    • Check command: UV_PROJECT_ENVIRONMENT=/home/agent/venv-py311 uv run --python 3.11 --extra dev ruff check && UV_PROJECT_ENVIRONMENT=/home/agent/venv-py311 uv run --python 3.11 --extra dev pytest && UV_PROJECT_ENVIRONMENT=/home/agent/venv-py313 uv run --python 3.13 --extra dev pytest → exit code None
    • Reviews performed: 1
    • Review repair cycles: 0/2
    • Review findings: not collected

    Details

    Handoff note: issue #245

    • issue: 245
    • started_at: 2026-10-14T14:44:28.136967Z
    • reason: token_soft_threshold
    • last_work_commit: 6bc8700

    Summary

    Implemented context telemetry for issue #245 (uncommitted at handoff): simple_coding_agent/model_execution.py tracks the context window/threshold via the SDK get_context_usage() call at session start and after each compaction only (basis sdk_assumed, or configured when CLAUDE_CODE_MAX_CONTEXT_TOKENS is set; failures yield unavailable with a reason and never affect the attempt), compaction count/last (at, trigger, pre_tokens, post_tokens) from compact_boundary events with post filled from the follow-up usage total, and a subagent registry keyed by Task tool_use_id with running flags cleared on Task tool results (view capped at 20, running first, newest first). simple_coding_agent/telemetry.py builds context.{main,main_peak,window,auto_compact_threshold,compactions,subagents} with figure invariants, and the tracer carries an unavailable context section. New tests/test_telemetry_context.py (untracked) covers window basis with/without the override, failed usage, compaction count/last plus re-reading, and subagent ordering plus the 20-entry cap.

    Remaining work

    1. Invoke the code-review skill on the diff and address findings.
    2. Commit the implementation (model_execution.py, telemetry.py, tests/test_telemetry_context.py) on agent/issue-245.
    3. Run the completion gate in order: (1) ruff check, (2) py3.11 pytest, (3) py3.13 pytest.

    Evidence

    • Branch state at handoff: M simple_coding_agent/model_execution.py, M simple_coding_agent/telemetry.py, ?? tests/test_telemetry_context.py (left uncommitted; sealing preserves them).
    • Prior turn results (pre-threshold): new context tests 11 passed; full py3.11 suite 1125 passed, 10 skipped; ruff check clean.

    Automatic continuation 0/2 used; the agent will continue automatically.

  5. added
    round-finishedAgent round finished; requires human evaluation to continue
    and removed
    ready-for-agentFully specified implementation issue ready for an unattended agent
    on Oct 14, 2026
  6. assigned and unassigned on Oct 14, 2026
  7. removed
    round-finishedAgent round finished; requires human evaluation to continue
    on Oct 14, 2026
  8. added a commit that references this issue on Oct 14, 2026
  9. lbacik commented on Oct 14, 2026

    @lbacik
    OwnerAuthor

    Agent Attempt Result: complete

    Branch: agent/issue-245
    PR: #255
    Merge: auto-merge enabled (merge)

    Evidence

    • Check command: UV_PROJECT_ENVIRONMENT=/home/agent/venv-py311 uv run --python 3.11 --extra dev ruff check && UV_PROJECT_ENVIRONMENT=/home/agent/venv-py311 uv run --python 3.11 --extra dev pytest && UV_PROJECT_ENVIRONMENT=/home/agent/venv-py313 uv run --python 3.13 --extra dev pytest → exit code 0
    • Reviews performed: 1
    • Review repair cycles: 0/2
    • Review findings: not collected

    Details

    Claude SDK completed the implementation workflow.

  10. removed their assignment
    on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions