Skip to content

Kiro: drop the private final answer when a real tool call shares the turn - #7437

Draft
hedging8563 wants to merge 1 commit into
lidge-jun:devfrom
hedging8563:bylinelog/kiro-final-answer-502
Draft

hedging8563 wants to merge 1 commit into
lidge-jun:devfrom
hedging8563:bylinelog/kiro-final-answer-502

Conversation

@hedging8563

@hedging8563 hedging8563 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem: The model can send a real tool call and the private final-answer call in one turn. The parser treated both orders as a protocol error; the client got a non-retryable 502 and a combo cannot fall back once a tool event is out.

Fix: The turn continues through the real tools. The parser drops the completion call, ends the turn with endTurn false and logs "[kiro] dropped the private final-answer call". The answer is held until the stream ends and never relayed. Completion first then real tool: only ordinary prose is released as commentary. A second completion, a completion while explicit completion is disabled, and a malformed completion stay errors.

Tests: new tests/providers/kiro/kiro-completion-with-real-tools.test.ts (17 cases, 10 fail without the change); kiro-stream test updated. tsc --noEmit clean; tests/providers/kiro (665 pass, 0 fail); test-layout 27 pass. No overlap with #7389 or later dev commits.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

…turn

The model can send a real tool call and the private final-answer call
in one turn, because the prompt tells it to put independent calls in
one block. The parser treated both orders as a protocol error. The
client got a non-retryable 502, and a combo cannot fall back once a
tool event is out.

Now the turn continues through the real tools. The parser drops the
completion call, ends the turn with endTurn false, and logs one line:
"[kiro] dropped the private final-answer call". The answer is held until
the stream ends and is never relayed, so the drop has no client-visible
effect. In the order "completion first, then real tool", only the
model's ordinary prose is released, as commentary with the tool call.

These stay errors: a second completion call, a completion call while
explicit completion is disabled, and a malformed completion.

Tests: new tests/providers/kiro/kiro-completion-with-real-tools.test.ts
covers both orders, several real tools, the bounded retry leg, a plain
completion, two completions, a malformed completion and the disabled
mode, for the streamed and the buffered parse. 10 of its 17 cases fail
without the change. The old kiro-stream case that expected an error for
the mixed turns now only keeps the duplicate completion.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This PR stays in draft until every box above is ticked.

@Ingwannu

Copy link
Copy Markdown
Owner

Follow-up intake at 7cbdc795bb7ede92c32cabc8ea28059b9a06d0b1 against dev 12025981e5a304cdb6b1b54f525ba8554f623977. Same-head duplicate: #7434. Holding the private completion until the stream ends avoids exposing it before a later real tool call, and both orders must finish as tool work rather than emit a final answer. Keep duplicate completion, malformed completion, disabled explicit-completion mode, cancellation, oversized held content and unknown/mixed events fail-closed; never replay after a real tool event committed output. Please retain one canonical PR, use the required Summary/Verification/Checklist template and refresh effective readiness. The author's 17 before/after cases and 665-case fixture receipt are not independently rerun here. No live Kiro inference or completion policy rollout occurred.

This branch has not been deployed

No deployments
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.

3 participants