mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-06 00:05:30 +00:00
Vertex rejects a function declaration whose parameters carry a keyword outside its Schema type: a live call with propertyNames returns 400 Unknown name "propertyNames" on every Gemini 4 model. zod-generated MCP tool schemas emit propertyNames for records, and Claude Code adds a deferred tool to tools[] once ToolSearch loads it, so every later request in the session fails with a 400. The cleaner now keeps only the fields of the Vertex v1 Schema type (https://docs.cloud.google.com/vertex-ai/docs/reference/rest/v1/Schema). The keywords it already dropped stay dropped. oneOf becomes anyOf when the node has no anyOf. A format value stays only when the reference lists it for the node's type. Every other dropped keyword is appended to the node's description as "[Constraint: key: value, ...]", in key order, the same hint shape as the antigravity schema cleaner. No tool is removed. Failure modes this commit guards against: - A non-Vertex keyword (propertyNames, not, if/then/else, allOf, prefixItems, contains, uniqueItems, multipleOf, exclusiveMaximum, unevaluated*, dependentSchemas, dependencies, ...) reaches parameters at any depth and Vertex returns 400. - oneOf is sent under its own name, or its branches are lost. - A format the reference does not list (uri, uuid) is sent, or a listed one (date, date-time, int64, double) is dropped. - A dropped constraint disappears without a trace for the model. - A property whose name equals a keyword (not, format, propertyNames) is dropped. - The same schema gives different request bytes on two turns, which breaks implicit prefix caching. - A tool is removed from functionDeclarations. Test changes: - TestCleanToolSchema_PreservesNestedOneOfCombinator becomes TestCleanToolSchema_MapsNestedOneOfToAnyOf: oneOf is not a Vertex Schema field, so the branches now arrive under anyOf. - TestCleanToolSchema_TraversesRetainedSchemaValuedKeywords becomes TestCleanToolSchema_DropsNonVertexSchemaValuedKeywordsIntoDescription: additionalItems, unevaluatedItems, unevaluatedProperties and dependencies are not Vertex Schema fields, so they move into the description hint. - New: gemini_messages_tool_schema_test.go.