Skip to content

Fix 0083 zero-bound to exceed per section 5.5.15#236

Merged
chris-colinsky merged 1 commit into
mainfrom
fix/0083-zero-bound-utilization-skip
Jul 24, 2026
Merged

Fix 0083 zero-bound to exceed per section 5.5.15#236
chris-colinsky merged 1 commit into
mainfrom
fix/0083-zero-bound-utilization-skip

Conversation

@chris-colinsky

Copy link
Copy Markdown
Member

Follow-up to #235 (0083 completion path). Corrects the handling of a declared token-budget bound of 0 to match observability §5.5.15, per spec's coordination response.

The gap

PR A treated a declared bound of 0 as degenerate and skipped it for both §11.2 instruments (and emitted no exceeded signal). But §5.5.15's exceeded evaluation is a strict usage.prompt_tokens > input_max_tokens, so a 0 bound is exceeded by any positive usage. Skipping the exceeded signal diverged from the spec.

The fix

  • The evaluation helper now includes a 0 bound (gates each bound on is not None rather than truthiness, which had conflated a declared 0 with an undeclared None).
  • The exceeded span attribute (openarmature.llm.token_budget.exceeded) and the exceeded counter fire per the strict > formula, so a 0 bound reads as exceeded.
  • Only the utilization histogram sample is skipped for a 0 denominator, since actual / 0 has no defined ratio -- an omitted sample rather than a fabricated sentinel bucket.

Behavior is unchanged for every positive-bound case (fixtures 126-129 and the existing budget unit tests pass). Adds unit tests for both the input and total 0-bound paths.

A declared token budget bound of 0 was skipped for both metrics and
emitted no exceeded signal. Per observability section 5.5.15 the
exceeded test is a strict actual > max, so a 0 bound is exceeded by
any positive usage: the exceeded span attribute and the exceeded
counter must fire. Only the utilization histogram sample is skipped,
since actual / 0 has no defined ratio.

Narrow the evaluation helper to include a 0 bound (gate on
is-not-None, not truthy) and move the divide-by-zero guard to the
utilization record site alone.
Copilot AI review requested due to automatic review settings July 24, 2026 02:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates OpenArmature’s OTel token-budget observability to treat a declared token-budget bound of 0 as a real bound (not “unset”), aligning exceeded evaluation with observability §5.5.15 while avoiding an undefined utilization ratio.

Changes:

  • Adjust token-budget evaluation gating to include bounds where max_tokens == 0 (using is not None instead of truthiness).
  • Skip only the utilization histogram sample when the denominator is 0, while still emitting exceeded signals/counters per strict actual > max.
  • Add unit tests covering both input_max_tokens=0 and total_max_tokens=0 behaviors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/openarmature/observability/otel/observer.py Includes 0 bounds in exceeded evaluation while guarding utilization recording against division by zero.
tests/unit/test_observability_otel.py Adds regression tests asserting exceeded fires for 0 bounds and utilization samples are omitted.

@chris-colinsky
chris-colinsky merged commit 1a71c2b into main Jul 24, 2026
7 checks passed
@chris-colinsky
chris-colinsky deleted the fix/0083-zero-bound-utilization-skip branch July 24, 2026 02:14
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.

2 participants