Skip to content

fix(kiro): stop injecting placeholder user turn on tool-result turns - #5807

Merged
diegosouzapw merged 3 commits into
release/v3.8.43from
fix/port-pr-2183-kiro-empty-toolresult
Jul 2, 2026
Merged

diegosouzapw merged 3 commits into
release/v3.8.43from
fix/port-pr-2183-kiro-empty-toolresult

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Summary

  • Kiro's translator unconditionally injected the literal "(empty)" placeholder into userInputMessage.content whenever a flushed user turn had no accumulated text — even when the turn was a trailing tool-result-only turn (an agentic loop ending in assistant.tool_calls → tool result, with no follow-up user text). Kiro can read that placeholder as if the user actually typed it, disrupting the tool-use loop.
  • Fixed by only falling back to "(empty)" when the turn carries no context at all. When the turn already carries toolResults or images, the content is now left as an empty string instead.

Changes

  • open-sse/translator/request/openai-to-kiro.ts: flushPending's user branch now computes hasContext = pendingToolResults.length > 0 || pendingImages.length > 0 and only falls back to "(empty)" when hasContext is false (note: this keeps OmniRoute's existing "(empty)" placeholder for genuinely-bare turns — e.g. the assistant-first synthetic filler / session-id hashing logic elsewhere in the file still relies on that literal string; only this one site's unconditional fallback changes).
  • tests/unit/translator-openai-to-kiro.test.ts: new regression case builds a payload ending in {role:"assistant", tool_calls:[...]} → {role:"tool", tool_call_id, content} with no trailing user message, and asserts the resulting currentMessage.userInputMessage content is empty (not "(empty)") while userInputMessageContext.toolResults is still populated.

Attribution

Thanks to @jetmiky for the original implementation.

Testing

  • node --import tsx/esm --test tests/unit/translator-openai-to-kiro.test.ts — new case FAILs before the fix ('(empty)' !== ''), PASSes after; full 30-test suite green (zero regression, including the "prepends synthetic user when conversation starts with assistant" case that legitimately depends on the "(empty)" placeholder).
  • node --import tsx/esm --test tests/unit/translator-ai-sdk-image-parts.test.ts tests/unit/kiro-continue-filler-5231.test.ts — green (adjacent Kiro translator suites, no regression).
  • npm run typecheck:core — clean.
  • npx eslint open-sse/translator/request/openai-to-kiro.ts tests/unit/translator-openai-to-kiro.test.ts — 0 errors (pre-existing any warnings only).
  • npm run check:docs-sync — PASS.

Kiro accepts an empty user content field when the turn carries
toolResults or images (the agentic tool-loop case), so the "(empty)"
placeholder is only needed for a genuinely bare turn. Previously a
trailing tool-result-only turn (no follow-up user text) would have its
content unconditionally set to the literal "(empty)" placeholder, as
if the user had typed it, which can confuse Kiro. The check is scoped
to the flushPending "user" branch only, so the existing "(empty)"
placeholder used elsewhere (assistant-first synthetic filler / session
hashing) is unaffected.

Co-authored-by: Bima Jatmiko Abadi <bja.devs@gmail.com>
Inspired-by: decolua/9router#2183
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request prevents the translator from injecting the literal "(empty)" placeholder on trailing tool-result-only turns when converting OpenAI requests to Kiro. Instead, if tool results or images are present, the user content is allowed to remain empty, preventing Kiro from being confused by an artificial placeholder. A corresponding unit test has been added to tests/unit/translator-openai-to-kiro.test.ts to verify this behavior and prevent regressions. No review comments were provided, so there is no additional feedback.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@diegosouzapw
diegosouzapw merged commit 59de75c into release/v3.8.43 Jul 2, 2026
1 check was pending
@diegosouzapw diegosouzapw mentioned this pull request Jul 2, 2026
@diegosouzapw
diegosouzapw deleted the fix/port-pr-2183-kiro-empty-toolresult branch July 3, 2026 04:58
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
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