Skip to content

Serve a telemetry snapshot through agentctl telemetry --json #240

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

The tracer bullet for telemetry. Running agentctl telemetry --json inside an agent container returns a schema-v1 telemetry snapshot built without network or git I/O and without holding up other control commands. Identity and control are real. current_attempt and last_finished are null and recent_events is empty until later tickets fill them.

Acceptance criteria

  • The control socket accepts {"op": "telemetry"} and answers {"ok": true, "telemetry": <snapshot>}.
  • agentctl telemetry --json prints the bare snapshot to stdout and exits 0. On failure it prints {"ok": false, "error": {"code", "message"}} to stdout: agent_unreachable (socket missing, refused or timed out; exit 2), unsupported_operation (agent answered "Unknown operation"; exit 1), snapshot_failed (agent could not build the snapshot, or the reply is unparsable or oversized; exit 1). No traceback escapes.
  • agentctl telemetry uses a 3 s connect+read timeout; other commands keep theirs. There is no human format, and status is unchanged.
  • A new telemetry module owns snapshot assembly behind a small reader interface (snapshot(control)); later tickets add its writer side (begin_attempt, publish_attempt, finish_attempt).
  • The snapshot carries schema_version: 1, generated_at, sequence (process-local), identity (repository, agent_version, sdk_version and cli_version from provenance evidence, and process_started_at recorded at startup), control, current_attempt: null, last_finished: null, recent_events: [], truncated: false.
  • control is the same payload status builds, produced by a network-free variant: no workspace dirty check and no GitHub lookups. Publication fields that would need a lookup are null ("not known yet"). It waits at most 1 s for the control lock. When the lock is busy it reuses the last built control section, and control_observed_at says when that section was built. If no section has been built yet, the reply is snapshot_failed.
  • The serialised snapshot is capped at 256 KiB: over the cap it drops recent_events oldest first, then current_attempt.context.subagents, and sets truncated: true.
  • The handler catches any exception, answers snapshot_failed, and emits a telemetry_failed event at most once per minute. It never takes down the control listener.
  • Tests: a snapshot is served while the main thread holds the control lock; the telemetry path performs no tracker or git calls (fakes that fail when called); each error code and exit code; the snapshot matches the shape of the idle example from the contract examples.

Blocked by

Activity

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

    @lbacik
    OwnerAuthor

    Agent Attempt Result: handoff

    Branch: agent/issue-240
    PR: none
    Handoff note commit: dc08872182bc2906fecc46a0135f625576fa730b

    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 #240

    • issue: 240
    • started_at: 2026-10-14T12:03:00.200226Z
    • reason: token_soft_threshold
    • last_work_commit: 69b15f1

    Summary

    Implemented the telemetry tracer bullet (agent-side telemetry over the control socket). All new tests pass (22/22 in tests/test_telemetry.py), full suite passes (1070 passed, 10 skipped), and ruff check is clean. The code-review skill was invoked in this run: Standards axis found 0 hard violations + 4 judgement-call smells; Spec axis found 0 missing requirements plus 2 partial gaps, 2 scope-creep notes, and 2 fragility findings (full report in the run transcript).

    What was built:

    • New simple_coding_agent/telemetry.py: TelemetryReporter (startup identity, process-local sequence, snapshot(control) reader interface, 256 KiB cap via apply_size_cap trimming oldest events then subagents), SnapshotFailedError, timeout/size constants.
    • lifecycle.py: AgentLifecycle(..., telemetry=...), telemetry_snapshot(), telemetry_control_snapshot() (≤1 s control-lock wait, reuse of last built section with control_observed_at, SnapshotFailedError when none built yet), plus network-free control-section/recovery builders (no workspace/tracker/publisher I/O; publication fields None).
    • control_server.py: {"op": "telemetry"} → {"ok": true, "telemetry": ...}; Unknown operation for readers without telemetry; snapshot_failed + rate-limited telemetry_failed event (60 s); new UnreadableReplyError; send_request(..., timeout=10.0) default unchanged.
    • agentctl.py: telemetry --json (required flag) printing the bare snapshot, exit 0; failures print {"ok": false, "error": {"code", "message"}} to stdout with agent_unreachable→2, unsupported_operation/snapshot_failed→1; 3 s timeout; no tracebacks.
    • __main__.py: wires TelemetryReporter (provenance sdk/cli/agent versions, process_started_at) into AgentLifecycle.
    • tests/test_telemetry.py: socket/shape/sequence, lock-busy cache reuse and empty-cache failure, exploding-fake no-I/O tests (idle + retained hold with null publication), all CLI error codes/exits, 3 s black-hole timeout, size-cap unit tests, rate-limit test.

    Remaining work

    1. Decide whether to address code-review findings before finishing (most actionable: return a copy of the cached control section in telemetry_control_snapshot; move the final print(json.dumps(snapshot)) inside the telemetry try in agentctl.py; consider dropping the format_timestamp/identity extra public surface). None was applied — implementation work is disabled at handoff.
    2. Check whether the PytestUnhandledThreadExceptionWarning in the full-suite output is caused by the new tests (unverified; could be pre-existing).
    3. Run the completion gate commands in order (ruff + pytest on both venvs).
    4. Commit the work to branch agent/issue-240 (nothing committed yet; sealing will commit uncommitted work).

    Evidence

    • Modified: simple_coding_agent/__main__.py, simple_coding_agent/agentctl.py, simple_coding_agent/control_server.py, simple_coding_agent/lifecycle.py (460 insertions, 7 deletions per diff stat).
    • New: simple_coding_agent/telemetry.py, tests/test_telemetry.py.
    • Test results observed: tests/test_telemetry.py 22 passed; full suite 1070 passed, 10 skipped; ruff check clean.
    • Code-review report: delivered in the run transcript under ## Standards / ## Spec headings.

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

  4. 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
  5. assigned and unassigned on Oct 14, 2026
  6. removed
    round-finishedAgent round finished; requires human evaluation to continue
    on Oct 14, 2026
  7. lbacik commented on Oct 14, 2026

    @lbacik
    OwnerAuthor

    Agent Attempt Result: complete

    Branch: agent/issue-240
    PR: #249
    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.

  8. 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