Skip to content

fix(hashline-edit): remove array type from lines union to fix Gemini Vertex schema validation#2425

Open
MoerAI wants to merge 1 commit intocode-yeongyu:devfrom
MoerAI:fix/issue-2408-gemini-vertex-edit-schema
Open

fix(hashline-edit): remove array type from lines union to fix Gemini Vertex schema validation#2425
MoerAI wants to merge 1 commit intocode-yeongyu:devfrom
MoerAI:fix/issue-2408-gemini-vertex-edit-schema

Conversation

@MoerAI
Copy link
Contributor

@MoerAI MoerAI commented Mar 10, 2026

Summary

Fixes #2408

When using Gemini models from Google Vertex AI, the hashline edit tool fails with:

"edit functionDeclaration parameters.edits.lines schema didn't specify the schema type field"

This does NOT happen with the original OpenCode edit tool, only with oMo's hashline-edit tool.

Root Cause

The lines parameter schema uses a union containing an array type:

union([string(), array(string()), null()])

When the OpenCode plugin SDK serializes this to Vertex AI's functionDeclaration format, the array(string()) member inside the union doesn't get a proper type: "array" field in the generated JSON Schema. Vertex AI requires all schema elements to have explicit type fields, 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's load_skills, ast-grep's paths).

Changes

  • src/tools/hashline-edit/tools.ts: Remove tool.schema.array(tool.schema.string()) from the lines union, keeping only string | null. Models will send newline-delimited strings instead of arrays.

Backward Compatibility

  • The execution code (normalize-edits.ts) still accepts string | string[] | null via RawHashlineEdit.lines - if any model sends an array, it will still be handled correctly
  • Claude/GPT models already commonly send strings for this parameter
  • The description is updated to clarify "newline-delimited string" format

Summary by cubic

Fixes Gemini Vertex AI schema validation in the hashline edit tool by removing the array type from the lines union. Addresses #2408 and allows edits to work reliably with Vertex.

  • Bug Fixes
    • lines schema now accepts string | null only; use newline-delimited strings.
    • Updated description text for clarity.
    • Runtime still accepts string[] for backward compatibility.

Written for commit 204322b. Summary will update on new commits.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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()])

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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.

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.

[Bug]: Gemini from Vertex Error: edit functionDeclaration parameters.edits.lines schema didn't specify the schema type field.

1 participant