fix: flatten suggest tool params to fix JSON parsing failures with Claude#11399
fix: flatten suggest tool params to fix JSON parsing failures with Claude#11399kilo-code-bot[bot] wants to merge 1 commit into
Conversation
| const actions: Array<{ label: string; prompt: string; description?: string }> = [ | ||
| { label: params.label, prompt: params.prompt, description: params.description }, | ||
| ] | ||
| if (params.label2 && params.prompt2) { |
There was a problem hiding this comment.
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.
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Reviewed by glm-5.2-20260616 · 853,033 tokens Review guidance: REVIEW.md from base branch |
Summary
actions: Schema.Array(...)parameter in thesuggesttool'sParamsschema with flat scalar fields (label,prompt,description,label2,prompt2,description2)actionsarray from these flat fields insideexecutebefore passing toSuggestion.showtool.txtguidance to describe the flat fields instead of the arrayThe 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.