Skip to content

fix: add context_tokens_total metric producer for alert rules - #420

Closed
Matthew-Selvam wants to merge 1 commit into
Conway-Research:mainfrom
Matthew-Selvam:fix/context-tokens-metric-producer
Closed

Matthew-Selvam wants to merge 1 commit into
Conway-Research:mainfrom
Matthew-Selvam:fix/context-tokens-metric-producer

Conversation

@Matthew-Selvam

Copy link
Copy Markdown

Summary

The context_near_capacity alert rule reads context_tokens_total but no code was publishing it. This renders the alert inert in production.

The Fix

Instrument buildContextMessages to estimate and publish the current context token count, enabling the alert to fire when context approaches budget limits (90% of 100k default).

Related

This is the §5.2 follow-up mentioned in the handoff document, addressing the inert context_near_capacity alert rule that 6 of 7 alert rules could never fire (#416).

Testing

  • Typecheck passes
  • Unit tests in alert-rules-wiring.test.ts verify the rule can fire with the metric

The context_near_capacity alert rule reads context_tokens_total but no code
was publishing it. This renders the alert inert in production.

Instrument buildContextMessages to estimate and publish the current context
token count, enabling the alert to fire when context approaches budget limits.
@Matthew-Selvam

Copy link
Copy Markdown
Author

Superseded by PR #416 - all alert rule fixes consolidated into single PR. The context_tokens_total metric producer has been merged into #416.

@Matthew-Selvam
Matthew-Selvam deleted the fix/context-tokens-metric-producer branch October 5, 2026 12:34
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