Skip to content

fix: flatten suggest tool params to fix JSON parsing failures with Claude#11399

Open
kilo-code-bot[bot] wants to merge 1 commit into
mainfrom
session/agent_27f76170-214c-4c51-bf32-85e0ebf1a727
Open

fix: flatten suggest tool params to fix JSON parsing failures with Claude#11399
kilo-code-bot[bot] wants to merge 1 commit into
mainfrom
session/agent_27f76170-214c-4c51-bf32-85e0ebf1a727

Conversation

@kilo-code-bot

@kilo-code-bot kilo-code-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace the nested actions: Schema.Array(...) parameter in the suggest tool's Params schema with flat scalar fields (label, prompt, description, label2, prompt2, description2)
  • Assemble the internal actions array from these flat fields inside execute before passing to Suggestion.show
  • Update tool.txt guidance to describe the flat fields instead of the array
  • Update all test calls to use the flat shape

The nested array schema causes JSON parsing failures with Claude models, which struggle to produce valid JSON for array-valued tool parameters. The flat scalar schema is unambiguous and parses reliably.

const actions: Array<{ label: string; prompt: string; description?: string }> = [
{ label: params.label, prompt: params.prompt, description: params.description },
]
if (params.label2 && params.prompt2) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

SUGGESTION: The flat schema can't enforce that label2 and prompt2 arrive together.

The previous array schema validated each action against Suggestion.ActionSchema (which requires both label and prompt), so a malformed second action would fail at the schema layer. With the flat fields, if a model emits label2 without prompt2 (or vice versa), this if silently drops the second action and the user only sees one button — the model gets no signal that its intended second action was discarded. Since the whole motivation here is Claude emitting partial/malformed JSON, this is exactly the case to guard against.

Two options: (1) enforce consistency in the schema (e.g. a refine/check requiring label2 and prompt2 together), or (2) at minimum log.warn here when only one of the pair is present so a dropped second action is observable. The tool.txt guidance also doesn't mention that label2 and prompt2 are required together — worth stating explicitly.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/opencode/src/kilocode/suggestion/tool.ts 80 Flat schema can't enforce label2/prompt2 arrive together; inconsistent pairs are silently dropped
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
packages/opencode/test/kilocode/suggestion/tool.test.ts The new two-action (label2/prompt2) branch in execute is untested. All test conversions exercise single-action calls only; consider adding a case that passes label2/prompt2 to cover the if (params.label2 && params.prompt2) push path.
.changeset/ No changeset for this bug fix. It changes the suggest tool's parameter schema (LLM-facing). If this surfaces in release notes as a fix for Claude JSON failures, a changeset is warranted; otherwise acceptable as an internal fix.
Files Reviewed (3 files)
  • packages/opencode/src/kilocode/suggestion/tool.ts - 1 issue
  • packages/opencode/src/kilocode/suggestion/tool.txt
  • packages/opencode/test/kilocode/suggestion/tool.test.ts

Fix these issues in Kilo Cloud


Reviewed by glm-5.2-20260616 · 853,033 tokens

Review guidance: REVIEW.md from base branch main

@alex-alecu alex-alecu self-assigned this Jun 18, 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