Skip to content

fix(estimator): stop infinite re-estimation loop + enrich context#6

Open
pablo-ibco wants to merge 2 commits into
mainfrom
pablo/fix-estimator-loop
Open

fix(estimator): stop infinite re-estimation loop + enrich context#6
pablo-ibco wants to merge 2 commits into
mainfrom
pablo/fix-estimator-loop

Conversation

@pablo-ibco

Copy link
Copy Markdown
Contributor

The bug

The estimator was burning credit re-scoring the same 10 issues every 2 minutes forever, because the polling filter estimate: null never excludes issues we've already commented on (the comment doesn't set the estimate).

Cost impact: ~$36/month for a backlog that should cost ~$2/month.

The fix

After posting our estimation comment, attach an ai-estimated label to the issue. Polling filter now excludes that label, so each issue is processed exactly once.

Bonus: better estimates

While in there, enriched the prompt context to include:

  • Parent epic title + description (was missing)
  • Top-5 similar past completed issues with their estimate vs actual cycle time (real grounding signal, was missing)
  • Global calibration baseline (already there)

The bulk of the estimate now sees concrete past examples in the same area, not just a global average.

Test

  • fetch_unestimated_issues filter excludes ai-estimated label
  • mark_issue_as_estimated adds the label after each comment
  • fetch_similar_completed_issues ranks by label overlap
  • estimate_issue now accepts and uses similar_issues in the prompt
  • syntax check passes

Deploy

Will deploy directly to AWS after merge.

Made with Cursor

pablo-ibco and others added 2 commits June 26, 2026 10:35
…h context

Two issues with the AI Estimation Engine in production:

1. **Infinite re-estimation loop**: the polling query filters by
   `estimate: null`, but the agent only posts a comment without setting the
   numeric estimate. Every 2 minutes the same backlog re-appears and gets
   re-scored. Burns ~$1/day on AWS doing nothing useful.

   Fix: after posting the comment, attach an `ai-estimated` label to the
   issue and add `labels.name: { neq: "ai-estimated" }` to the polling
   filter so each issue is scored exactly once. Label auto-creates on
   first use.

2. **Estimate quality was thin**: the prompt only had title + description
   + labels + a global historical average. Strengthened to include:

   - Parent epic title + description (issue's business context)
   - Initiative / project description (broader strategic context)
   - Top-5 most-similar completed past issues by label overlap, including
     their estimate vs actual cycle time (real grounding signal)
   - Global calibration baseline (kept)

   Cost impact: slightly more tokens per call (~+500 tokens), still
   ~$0.005 per estimate on Haiku 4.5. With the loop fix, total spend
   on the estimator goes from ~$30/month to ~$2/month for our backlog.

Result: each new ticket is scored once with much richer context. Demo-ready.
Co-authored-by: Cursor <cursoragent@cursor.com>
…ching label)

Co-authored-by: Cursor <cursoragent@cursor.com>
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