Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

Feature: Overflow-Aware Test Triage & Follow-Up Tasks

Open orialmog opened this issue 1 year ago • 2 comments

Feature Description

Feature Description: Overflow‑Aware Test Triage & Follow‑Up Tasks

Problem this solves

Large diffs, long conversations, and verbose logs can exhaust an LLM’s context window before all tests are fixed. The model often stops after partial progress, leaving failing tests that require the developer to re‑triage, rebuild context, and manually plan next steps.

Desired outcome

  • Developers never lose momentum after a partial fix.
  • The editor auto-produces a concise Summary of Issues and a Follow‑Up Task Pack—small, actionable tasks mapped to failing tests/root causes.
  • Each task comes with just enough context to act, without blowing the token budget.

How it should work (flow)

  1. Detect overflow & partial completion
    Track token budget and test status. If failing tests remain or model confidence drops as the window nears capacity, switch to wrap‑up mode.
  2. Generate Summary of Issues
    Group failures by root cause; extract minimal, lossless evidence (test names, assertion messages, stack frames, first failing line, suspected modules); deduplicate noisy logs.
  3. Build a Follow‑Up Task Pack
    Produce 3–7 atomic tasks, each tied to specific failing tests or a root cause. Include: goal, steps, file hints, code anchors, and a micro‑context budget. Order by impact/dependency.
  4. Smart context budgeting
    Reserve tokens for (a) the issue summary, (b) the next task’s local snippets only, and (c) an ultra‑brief plan. Use retrieval to load only referenced code spans (not entire files).
  5. Tight feedback loop
    After each task is applied, re‑run the targeted tests and update the summary & remaining tasks. If all pass, auto‑collapse the pack and mark the session green.

UX details (at a glance)

  • Drawer: Summary of Issues — chips by root cause; each chip expands to failing tests, first failing line, and links to code anchors.
  • Panel: Follow‑Up Task Pack — task cards with title, brief description, effort (S/M/L), targeted tests, and actions (Apply fix, Open files). Keyboard‑first: ↑/↓ select, ⏎ open, ␣ run targeted tests. Toggle: “Auto‑Run Targeted Tests after Apply” (default on).

Non‑goals

  • Whole‑repo context ingestion or unlimited context expansion.
  • Full flaky‑test remediation (flakiness is detected and labeled; deeper infra work is out of scope).

Acceptance criteria

  • If the agent stops with any failing tests, a Summary and ≥1 Follow‑Up Task appear automatically.
  • Each task links to ≥1 failing test and ≥1 code anchor.
  • Running a task triggers only the minimal necessary tests.
  • Token spend with wrap‑up enabled is ≤ baseline + 15% for the same scenario.
  • After all pass, the Summary auto‑updates to All tests passing.

Use Case

Use Case: Overflow‑Aware Test Triage & Follow‑Up Tasks

Scenario

You’re refactoring date parsing. The session includes long logs and a big diff. The model fixes some code, but the context is nearly full and several tests still fail.

Before (today)

  • Model stops after partial progress.
  • You manually scan test output, infer root causes, and plan next steps.
  • High chance of repeating context or missing details.

After (with this feature)

  1. Wrap‑up mode triggers automatically as the window nears capacity and failing tests remain.
  2. The editor shows a Summary of Issues:
    • Root cause: Timezone normalization
      • tests/test_parser.py::test_z_suffix → expected UTC, got naive datetime (line 42)
      • tests/test_parser.py::test_offset_minutes → off by +60s (line 67)
    • Root cause: Null handling in to_dict()
      • tests/test_model.py::test_optional_field → KeyError on None (line 103)
  3. A Follow‑Up Task Pack appears:
    • Normalize timezone handling in parse_iso (S)
      Steps: treat Z as +00:00, support ±HH:MM, round to whole seconds.
      Targets: test_z_suffix, test_offset_minutes.
    • Guard nulls in Model.to_dict (S)
      Steps: default to None, exclude empty keys, update schema docs.
      Targets: test_optional_field.
  4. You select the first task, which loads only the relevant code snippets and runs only the targeted tests.
  5. After applying both tasks, all targeted tests pass; the pack collapses and the session turns green.

Quick start (user actions)

  • Open the Follow‑Up Task Pack panel → pick Task 1 → Apply fix → targeted tests auto‑run.
  • Repeat for remaining tasks; commit with the auto‑generated PR section appended.

Success criteria in this use case

  • Time‑to‑green improves vs. baseline.
  • No manual re‑triage needed between partial completions.

Additional Context

Additional Context: Overflow‑Aware Test Triage & Follow‑Up Tasks

Rationale & constraints

  • Designed for sessions where token budget is tight and failures remain.
  • Emphasizes lossless, minimal evidence in summaries to avoid noise and token bloat.

Signals & heuristics

  • Trigger wrap‑up when: remaining token budget < threshold and (failing tests > 0 or confidence < threshold).
  • Confidence derived from: completion likelihood, unresolved references, and diff size vs. touched tests.

Telemetry & metrics

  • Time‑to‑Green (from first run to all tests passing)
  • Tasks per failure (target < 1.5)
  • Redundant token spend (unused context share)
  • Adoption (rate of accepting suggested tasks)
  • Flake detection rate and false‑positive rate

Edge cases

  • Flaky tests → detect via non‑deterministic outcomes across two runs; label and deprioritize.
  • Infra errors (OOM/timeout) → produce infra tasks (e.g., split fixture, mock network) instead of code fixes.
  • Cross‑repo breakages → add a “Context debt” task to fetch external contracts/specs.

Implementation notes

  • Retrieval loads only referenced functions/blocks + closest tests.
  • Two‑stage prompting: (1) summarize failures; (2) propose tasks with anchors.
  • Safety rails: prevent task generation if test results are stale; force targeted re‑run first.

Open questions

  • What’s the default token reservation for wrap‑up (e.g., 12%)?
  • How should we expose confidence to users (raw vs. bucketed)?
  • Should the pack persist across sessions or be regenerated each time?

orialmog avatar Aug 24 '25 22:08 orialmog

Hi @orialmog , Thank you for creating this feature request and adding detailed use-case.

harshchheda-aws avatar Sep 05 '25 16:09 harshchheda-aws

Thanks for taking the time to file this and for the feedback! We're doing a periodic backlog review and noticed this issue hasn't seen activity in over 6 months. Given how much has changed in Kiro since then (we're now on IDE 1.0.293 / CLI 2.18.0), we can't be confident it's still relevant on current builds.

We're closing this to keep the backlog focused, but it's not a dismissal — if you're still seeing this or the idea still resonates, we'd genuinely welcome a new issue with your current version and any updated context. Issues with 👍 reactions or detailed reproduction steps rise to the top fastest.

Appreciate the input! 🙏

AnilMaktala avatar Aug 14 '26 19:08 AnilMaktala