Skip to content

fix: drop unsupported JSON Schema format from tool parameters (422) - #4

Open
PetrIIvanov wants to merge 1 commit into
Overman775:mainfrom
PetrIIvanov:fix/format-422
Open

PetrIIvanov wants to merge 1 commit into
Overman775:mainfrom
PetrIIvanov:fix/format-422

Conversation

@PetrIIvanov

Copy link
Copy Markdown

Problem

GigaChat API only accepts format values date, date-time or time. opencode sends tool schemas (e.g. webfetch) with format: "uri", which makes the API reject the whole request with 422 INVALID_PARAMS before any response is produced.

Fix

sanitizeFunctionParameters in src/plugin/tools.ts now filters out any format value outside the allowed set, so unsupported formats are dropped from the schema instead of failing the request.

Tests

Added a unit test covering that format: "uri" is dropped while date/date-time/time are preserved. All 77 tests pass.

Fixes the GigaChat Translation Proxy Error 422 (Value properties.url.format must be one of: date, date-time, time).

GigaChat API only accepts format 'date', 'date-time' or 'time'. Other
JSON Schema formats such as 'uri' (used by webfetch tool schemas) cause
the API to reject the request with 422 INVALID_PARAMS. sanitizeFunctionParameters
now filters out any format value outside the allowed set.
@PetrIIvanov

Copy link
Copy Markdown
Author

Локальная проверка (Node 20, эквивалент всех шагов CI):

  • npm test → 77/77 passed (включая новый тест на format)
  • npm run build:release → OK (tsc без ошибок, бандл собирается)
  • npm run test:release → standalone release passes without node_modules

Воспроизведение бага: GigaChat-API возвращал 422 INVALID_PARAMS (Value properties.url.format must be one of: date, date-time, time) на любой запрос, где opencode передавал схему инструмента с format: "uri" (например, webfetch). Ответ модели не приходил вовсе.

Фикс в sanitizeFunctionParameters закрывает именно этот класс ошибок для всех инструментов. Реальный агентный цикл (инструмент → ответ) проверен и работает.

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