You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Publish live budget, token, turn and cache figures in telemetry #244
During model execution, telemetry shows the current attempt's budget, token, turn and cache figures as they change, each tagged with its figure basis. When model execution ends they freeze at their final values.
Acceptance criteria
The executor receives an injected publisher (like its event log) and publishes an immutable attempt view after every limit check. Publishing is a reference swap under a lock held only for the swap. The listener thread never reads the token ledger.
budget.used (measured when its estimated part is 0, otherwise estimated), budget.measured, budget.estimated, budget.hard_ceiling_reached, and budget.soft_threshold with value (the effective threshold after the handoff reserve), rule (percentage or reserve), percentage, reserve_turns, crossed, crossed_at_tokens, crossed_at. The soft threshold is configured under percentage; under reserve it inherits the main context's basis.
tokens_by_category (input_tokens, cache_read_input_tokens, cache_creation_input_tokens, output_tokens; measured part only), turns (main-thread responses, measured), cache.main_hit_rate with counted (unavailable below the configured minimum of measured responses), elapsed_seconds (measured).
provider_rate_limit is always {value: null, basis: "unavailable", reason: "not exposed through the gateway"}. No USD figure is sent.
observed_at and sequence advance with every publication. After model execution ends, the view stays frozen at its final values until finalisation.
Tests: figures and bases match the attempt-in-progress and soft-threshold-crossed contract examples' shape; a failing publish does not affect the attempt; frozen after execution.
Implemented live attempt-figure publication for telemetry (issue #244, "publish the attempt's budget/token/turn/cache figures as they change"). All code changes are written but uncommitted (sealing will commit them):
simple_coding_agent/token_ledger.py: added main_measured_response_count and main_context_basis() (measured when the main thread's latest response reported usage, else estimated).
simple_coding_agent/telemetry.py: TelemetryReporter.publish_attempt_view() stamps observed_at and swaps the stored view under _attempt_view_lock (held only for the swap); _build_current_attempt serves the published view merged with the claim seed (full shape: budget used/measured/estimated + hard ceiling + soft threshold with rule/percentage/reserve_turns/crossed/crossed_at_tokens/crossed_at, tokens_by_category, turns, cache.main_hit_rate with counted, elapsed, provider_rate_limit, no USD). Without a published view it keeps the old tracer shape. begin_attempt/finish_attempt clear the view.
simple_coding_agent/model_execution.py: ModelExecutor takes injected attempt_publisher (ctor param + set_attempt_publisher, like event_log), publishes an immutable MappingProxyType view at the end of every _check_limits, records soft-threshold crossing wall-time, logs telemetry_publish_failed without affecting the attempt on publisher failure.
simple_coding_agent/lifecycle.py: _wire_attempt_telemetry_publisher() wires reporter.publish_attempt_view into the executor before dispatch; called alongside _wire_attempt_runner_handoff().
Invoke the code-review skill on the changes (required by the completion gate; an attempt with commits but no code-review invocation counts as incomplete).
Run the completion gate in order: ruff check, full pytest on Python 3.12, full pytest on Python 3.13 (env vars redacted in the issue; PATH/HOME/UV_PYTHON_INSTALL_DIR/UV_PYTHON_DOWNLOADS/UV_NO_PROGRESS are set by the gate).
Address any review/gate findings, then commit to agent/issue-244.
Evidence
New tests: UV_PROJECT_ENVIRONMENT=/tmp/venv-py3-check uv run --python 3.12 --extra dev pytest tests/test_telemetry_live_figures.py → 13 passed.
Related suites (test_telemetry, test_telemetry_examples, test_model_execution, test_prompt_cache, test_lifecycle) → 206 passed.
Full suite on 3.12 → 1099 passed, 10 skipped (one pre-existing PytestUnhandledThreadExceptionWarning about recovery, unrelated).
ruff check → all checks passed.
NOT yet run: code-review skill, full pytest on Python 3.13, gate with the official env.
Automatic continuation 0/2 used; the agent will continue automatically.
Activity
lbacik commentedon Oct 14, 2026
Agent Attempt Result: handoff
Branch: agent/issue-244
PR: none
Handoff note commit:
b1980f444ae4e69e48cf8a3dbb532f1ed8f513f5Evidence
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 NoneDetails
Handoff note: issue #244
Summary
Implemented live attempt-figure publication for telemetry (issue #244, "publish the attempt's budget/token/turn/cache figures as they change"). All code changes are written but uncommitted (sealing will commit them):
simple_coding_agent/token_ledger.py: addedmain_measured_response_countandmain_context_basis()(measured when the main thread's latest response reported usage, else estimated).simple_coding_agent/telemetry.py:TelemetryReporter.publish_attempt_view()stampsobserved_atand swaps the stored view under_attempt_view_lock(held only for the swap);_build_current_attemptserves the published view merged with the claim seed (full shape: budget used/measured/estimated + hard ceiling + soft threshold with rule/percentage/reserve_turns/crossed/crossed_at_tokens/crossed_at, tokens_by_category, turns, cache.main_hit_rate with counted, elapsed, provider_rate_limit, no USD). Without a published view it keeps the old tracer shape.begin_attempt/finish_attemptclear the view.simple_coding_agent/model_execution.py:ModelExecutortakes injectedattempt_publisher(ctor param +set_attempt_publisher, likeevent_log), publishes an immutableMappingProxyTypeview at the end of every_check_limits, records soft-threshold crossing wall-time, logstelemetry_publish_failedwithout affecting the attempt on publisher failure.simple_coding_agent/lifecycle.py:_wire_attempt_telemetry_publisher()wiresreporter.publish_attempt_viewinto the executor before dispatch; called alongside_wire_attempt_runner_handoff().tests/test_telemetry_live_figures.py(new, 13 tests): example-shape conformance for attempt-in-progress and soft-threshold-crossed, used-basis rule, hit-rate unavailability below minimum, observed_at/sequence advance, immutable per-check publication, failing-publish safety, frozen-after-execution, detached listener copy, begin/finish clearing, ledger helpers, lifecycle wiring.Remaining work
code-reviewskill on the changes (required by the completion gate; an attempt with commits but nocode-reviewinvocation counts as incomplete).ruff check, fullpyteston Python 3.12, fullpyteston Python 3.13 (env vars redacted in the issue; PATH/HOME/UV_PYTHON_INSTALL_DIR/UV_PYTHON_DOWNLOADS/UV_NO_PROGRESS are set by the gate).agent/issue-244.Evidence
UV_PROJECT_ENVIRONMENT=/tmp/venv-py3-check uv run --python 3.12 --extra dev pytest tests/test_telemetry_live_figures.py→ 13 passed.test_telemetry,test_telemetry_examples,test_model_execution,test_prompt_cache,test_lifecycle) → 206 passed.PytestUnhandledThreadExceptionWarningabout recovery, unrelated).ruff check→ all checks passed.code-reviewskill, fullpyteston Python 3.13, gate with the official env.Automatic continuation 0/2 used; the agent will continue automatically.
Handoff note: issue #244
Seal attempt work for #244 (model_limit_reached)
Address code-review findings for #244 (deep-freeze published view, wi…
lbacik commentedon Oct 14, 2026
Agent Attempt Result: complete
Branch: agent/issue-244
PR: #254
Merge: auto-merge enabled (merge)
Evidence
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 0Details
Claude SDK completed the implementation workflow.