feat(decay): add LLM-assisted relevance recheck at maturity thresholds#27
Merged
foundatron merged 1 commit intomainfrom Mar 11, 2026
Merged
feat(decay): add LLM-assisted relevance recheck at maturity thresholds#27foundatron merged 1 commit intomainfrom
foundatron merged 1 commit intomainfrom
Conversation
…ccelerate actions - Update DECAY_CHECK prompts to return action/reasoning/comment schema - Add `comment_on_issue()` and `close_issue()` to issues.py (list args, no shell) - Add `get_analysis_by_id()` to db.py - Expand `apply_decay()` with llm_client, context, repo, model, dry_run params - LLM recheck fires at 4→3 and 2→1 maturity threshold crossings - Halt: skip decay, log entry, optionally post GitHub comment - Accelerate: drop to maturity 1, close issue, update DB status - BudgetExceededError disables LLM for remaining issues in the run (fail-open) - Any non-budget LLM failure defaults to mechanical decay (fail-open) - Issues decaying to maturity 1 are auto-closed via gh CLI + DB status update - Add `decay_model` config field (default: claude-haiku-4-5) - Wire LLM client and --dry-run flag into cmd_review_backlog - Add 12 new decay tests and 5 new issues tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11
Changes
1.
tentacle/llm/prompts.py— Update decay check promptsDECAY_CHECK_SYSTEMoutput schema from{"still_relevant": bool, "reasoning": "..."}to{"action": "halt"|"decay"|"accelerate", "reasoning": "...", "comment": "..."}halt= still relevant, skip decay;decay= proceed with normal -1;accelerate= no longer relevant, drop to 1commentfield is optional, used for GitHub issue comments on halt/accelerateDECAY_CHECK_USERtemplate: no structural changes needed, just ensure theactionvocabulary is documented in the system prompt2.
tentacle/decay.py— Add LLM recheck at threshold crossingsapply_decaysignature:apply_decay(store: Store, *, grace_days: int = 30, interval_days: int = 60, llm_client: LLMClient | None = None, context: str = "", repo: str = "", model: str = "claude-haiku-4-5", dry_run: bool = False) -> intnew_maturitybut before applying, check if the decay crosses a threshold (4→3 or 2→1)_llm_recheck()which:store.get_analysis_by_id(issue.analysis_id)— usessuggested_body(or"(no body available)"if None)llm_client.complete()with decay check prompts using the configured modelRecheckResult(NamedTuple:action: Literal["halt", "decay", "accelerate"],reasoning: str,comment: str)DecayEntrywith reason"llm_recheck:halt — {reasoning}", callcomment_on_issue()ifcommentis non-emptynew_maturity = 1, logDecayEntrywith reason"llm_recheck:accelerate — {reasoning}", callclose_issue()with comment, callstore.update_issue_status(issue_id, "closed")close_issue()+store.update_issue_status()BudgetExceededErrorinside the per-issue loop: log warning, setllm_client = Nonefor remaining iterations (mechanical decay only)llm_client is None, skip LLM recheck entirely (backward compat)3.
tentacle/issues.py— Addclose_issue()andcomment_on_issue()comment_on_issue(issue_number: int, comment: str, *, repo: str, dry_run: bool = False) -> boolsubprocess.run(["gh", "issue", "comment", str(issue_number), "--repo", repo, "--body", comment], ...)— list args, no shellclose_issue(issue_number: int, comment: str, *, repo: str, dry_run: bool = False) -> boolsubprocess.run(["gh", "issue", "close", str(issue_number), "--repo", repo, "--comment", comment], ...)gh issue close --commentsupport; if unavailable, fall back tocomment_on_issue()+close_issue()without--comment4.
tentacle/db.py— Addget_analysis_by_idget_analysis_by_id(self, analysis_id: int) -> Analysis | None— simpleSELECT * FROM analyses WHERE id = ?, reuses existing_row_to_analysisconverter5.
tentacle/cli.py— Wire LLM client intocmd_review_backlogcmd_review_backlog:CostTrackerandLLMClient(withconfig.scan_budget, monthly budget, etc.)fetch_context()pattern (same ascmd_run)llm_client,context,repo=config.target_repo,model=config.decay_model,dry_run=args.dry_runtoapply_decay()--dry-runflag toreview-backlogsubparser6.
tentacle/config.py— Adddecay_modelconfig fielddecay_model: str = "claude-haiku-4-5"toConfigdataclass (alongside existingfilter_modelandanalyze_model)_apply_tomlmapping andDEFAULT_CONFIG_TEMPLATEReview Findings
The most critical issue is #7 —
repodefaulting to""means any call toapply_decaywithout an explicitrepoargument (which is the case when no LLM client is configured, but mechanical decay still reaches maturity 1) will attemptgh issue close --repo ""and fail. The issue will be stuck open at maturity 1. Either makereporequired when close behavior is possible, or guard theclose_issuecall onrepobeing non-empty.