fix(hashline-edit): remove array type from lines union to fix Gemini Vertex schema validation#2425
Conversation
…Vertex schema validation (code-yeongyu#2408)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 204322b120
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| lines: tool.schema | ||
| .union([tool.schema.string(), tool.schema.array(tool.schema.string()), tool.schema.null()]) | ||
| .describe("Replacement or inserted lines. null/[] deletes with replace"), | ||
| .union([tool.schema.string(), tool.schema.null()]) |
There was a problem hiding this comment.
Restore array support in
lines schema
Removing string[] from the declared lines type makes the tool contract inconsistent with its own prompt text (src/tools/hashline-edit/tool-description.ts still says lines: string|string[]|null and calls string[] the preferred multi-line format). In any provider/runtime that validates tool arguments against the declared schema before execution, a model that follows those instructions will produce an array and the call will be rejected before normalize-edits.ts can apply its array fallback, so multi-line edits regress despite the backward-compatibility claim.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Fixes a specific validation error in Vertex AI by simplifying the schema union while maintaining execution-layer backward compatibility for array inputs.
Summary
Fixes #2408
When using Gemini models from Google Vertex AI, the hashline edit tool fails with:
This does NOT happen with the original OpenCode edit tool, only with oMo's hashline-edit tool.
Root Cause
The
linesparameter schema uses a union containing an array type:When the OpenCode plugin SDK serializes this to Vertex AI's
functionDeclarationformat, thearray(string())member inside the union doesn't get a propertype: "array"field in the generated JSON Schema. Vertex AI requires all schema elements to have explicittypefields, causing the validation error.This is the only tool in the codebase that nests an array inside a union. All other array usages are at the top level (e.g.,
delegate-task'sload_skills,ast-grep'spaths).Changes
src/tools/hashline-edit/tools.ts: Removetool.schema.array(tool.schema.string())from thelinesunion, keeping onlystring | null. Models will send newline-delimited strings instead of arrays.Backward Compatibility
normalize-edits.ts) still acceptsstring | string[] | nullviaRawHashlineEdit.lines- if any model sends an array, it will still be handled correctlySummary by cubic
Fixes Gemini Vertex AI schema validation in the hashline edit tool by removing the array type from the
linesunion. Addresses #2408 and allows edits to work reliably with Vertex.linesschema now acceptsstring | nullonly; use newline-delimited strings.string[]for backward compatibility.Written for commit 204322b. Summary will update on new commits.