ac4af582301a4e8a29245dbba767eba31334ddf9
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
837ea5f565 |
gateway: a Kimi tool schema with items is an array, not its enum's string, as Gemini's is now (#3867)
yetone, #3867: kimiSchemaType and collectUntypedEnums read an untyped schema's enum or const before its keywords, so a tool's {"items":{"type":"string"},"enum":["a","b"]} reached Kimi typed "string" with items beside it — the shape its Gemini sibling went out in until |
||
|
|
7bdf08f18d |
gateway: no type beside the $ref a Kimi schema's target is
kimiToolRefTypes wrote a type into each schema a tool's $refs reach that
has none. When the target was itself a $ref — zod writes one beside what
it changed of a reused schema, a format and a description among them, as
Codex's automation_update's targetThreadId reaches {"format":"uuid",
"description":"tt","$ref":"#/$defs/__schema1"} — the type went beside
that inner $ref, and Moonshot refuses one there, 400 "At path
'$defs.__schema14': when using $ref, type should be defined in the
referenced schema instead of the parent schema" (#3205), so every turn
failed though the tool is never called. The plugin side had the same bug
and fixed it in kimi-work 0.1.5.
The chain a $ref names is now followed to the schema it ends at, and it
is there the type goes, or nowhere when the chain ends at a ref to
nowhere or never ends: schemaTypes already resolved chains to say what
the type is, so only the place it is written moves. Codex's own
automation_update schema (the fixture its tests and magpie's root-union
tests share) goes as it was sent: its defs are notes beside a $ref to a
typed target, which Kimi takes.
Fixes #3205
Generated-by: GLM-5.3-Flash (ZCode)
|
||
|
|
7804dfbb03 |
gateway: drop the locked sampling fields for Kimi on Volcengine Ark too
Volcengine Ark's plans lock the sampling parameters of the Kimi models they serve: any request carrying temperature != 1 is refused 400 "Volcengine Ark: `temperature` only 1 is allowed for this model" (#4495, kimi-k3.1-pro / kimi-k3 / kimi-k2.8-preview at ark.cn-beijing.volces.com/api/coding/v3), before any token is read — clients that send their own defaults (Claude Code, Copilot) fail every call, and a routing group spends its failover window on each try. kimiLockedSampling already drops temperature and top_p for the locked models on Moonshot's own endpoints (#1197), but its isKimi guard knows only Moonshot's hosts and presets, so the same models behind an Ark host went through with the fields. The refusal names the model ("for this model"), not the path, and the preset's Agent Plan and pay-as-you- go regions list the same kimi-kX.Y models, so the guard now also takes isArk — the ark.<region>.volces.com check the draw and video code already uses, which covers the preset's plans and a provider added by hand — and kimiLockedSamplingModel keeps deciding per model, as it already does for kimi-k2.5 and later, kimi-for-coding* and k3*. Ark's other models (doubao, glm, deepseek, minimax) are untouched, as is everyone not served by Moonshot or Ark. Run: TestKimiLockedSampling in internal/gateway grew four cases (the coding plan's chat and anthropic routes, an Ark model the server doesn't lock, a provider added by hand on an Ark host): the three drop cases fail on the unmodified code and pass with it, the keep case passes throughout. go test -tags nogui ./internal/gateway ok (499s); gofmt clean; go vet -tags nogui on darwin, linux and windows clean; go build -tags nogui ./... on darwin, linux and windows ok. Generated-by: GLM-5.3-Flash (ZCode) Reviewed and run by yetone at the batch head over |
||
|
|
d71362afcd |
gateway: a Gemini tool schema with items is an array, not its enum's string, and Antigravity gets items only on arrays (ferock)
ferock on Discord: Claude Code, model group/gemini-3-8-flash on a local magpie whose group is served by a remote magpie's Antigravity, 400 "Remote magpie: Antigravity: GenerateContentRequest.tools[0]. function_declarations[19].parameters.properties[display].items: field predicate failed: $type == Type.ARRAY". It worked in the morning and broke after updating. The tool's literal schema wasn't posted, and no Claude Code 2.1.311 built-in has a display property with items (searched the binary), so it is an MCP tool of theirs. Cause: geminiToolTypes ( |
||
|
|
68ee4117af |
gateway: a Gemini model's untyped tool schemas go typed (Vertex refused cua-driver's drag)
kthink on Discord: dsh with cua-driver's MCP tools on Command Code's
google/gemini-3.8-flash (the commandcode plugin), every request 400
INVALID_REQUEST from Vertex: "`mcp__cua-driver__drag` functionDeclaration
`parameters.target` schema didn't specify the schema type field."
cua-driver's drag schema before cua's #4888 has target as an anyOf of an
untyped oneOf and null, and scope a const with no type. Command Code's
gateway turns JSON Schema into Vertex's Schema object, whose type is
required, and an untyped node stays untyped.
geminiToolTypes (forwardOnce, so plugin requests too) is keyed on the
model id (last '/' segment starts with "gemini"), not the provider:
each untyped schema under tools' function.parameters / parameters /
input_schema gets the type its enum/const, keywords or branches say,
null left out; {} or a description alone is a string, a tool root an
object. Mixed-type unions, unresolved $ref/unions and anything under
not/if are left as they came. Written in place after the brace, so the
rest of the body is unchanged. withTypes no longer writes a trailing
comma into an empty {} (it produced invalid JSON there).
Google's own Gemini API / Code Assist (parametersJsonSchema) and
Antigravity (plainSchema) bodies have no such tools and are not walked.
Run at this tree, rebased on origin/main
|
||
|
|
129d8b08a5 |
gateway: a schema a tool's $ref reaches goes to Kimi with a type
chaosy on Discord: Codex on Kimi Code k3 failed every request, 400 "not
a valid moonshot flavored json schema … $defs.__schema20 … must be
defined". Moonshot's validator expands each $ref and refuses a target
with no type ("At path 'properties.b': detected infinite recursion
without termination condition"), though the same schema written inline
passes. Codex sends its MCP and Codex App tools as zod's $defs and types
a def with properties or an enum, but leaves a oneOf or allOf def as it
was, so the whole request fails.
kimiToolRefTypes, scoped by isKimi and run in forwardOnce after
kimiToolEnumTypes (chat, Anthropic and Codex's Responses routes all pass
there), writes a type after the brace of each untyped $ref target: the
one its keywords or branches say, a type array when they differ, every
type when nothing does. {} targets, anyOf targets (Kimi refuses a type
beside an anyOf) and pure $ref chains are left alone. kimiToolEnumTypes
now also types an enum of one type plus null as [T,"null"], the one type
array Kimi takes beside an enum. Kimi doesn't count as a moved
subscription, so no plugin path reaches it.
Measured against the real Kimi Code chat endpoint
(api.kimi.com/coding/v1/chat/completions, a key without a plan, so a
schema that passes validation gets 403 access_terminated_error and a
refused one gets 400 first):
- Codex 0.162.1's processed shapes: 400 at properties.b before, 403
after.
- Raw shapes (properties-only, minLength-only, const, [1,null] enum,
description-only and oneOf-of-refs defs): 400 before, 403 after.
- The zod-built Codex App automation_update forms: 403 before and after.
- [T,"null"] plus enum, a type array beside oneOf, and every type beside
a description: 403.
The Anthropic endpoint answers 403 before it validates, so it couldn't
be probed; the same rewrite reaches it.
Tests: TestKimiToolRefTypes posts on /v1/chat/completions, /v1/messages
and /v1/responses to Kimi and to another provider, which gets the tools
unchanged. With the forwardOnce line removed it fails on all three
Kimi routes. TestKimiToolEnumTypes now expects [T,"null"] for
["a",null], and fails with that branch removed.
Run at this head: gofmt -l (clean); go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... (clean);
set -o pipefail; HOME=<sandbox> go test -timeout 45m ./... at
|
||
|
|
64498df78f |
kimi: 将被拒绝的采样参数改写为可接受的值 (#1197)
* kimi: rewrite refused sampling params to the accepted values VS Code Copilot's chat hardcodes temperature 0.1 and top_p 1, which Kimi Code's per-model whitelist refuses with 400 "invalid temperature: only 1 is allowed for this model" before any token is read. Rewrite them to the accepted values (1, 0.95) in the body before forwarding, and add them when absent; a request already carrying them, or going to another provider, is left as it was. Tested with the four cases: refused, absent, accepted, another provider. * kimi: drop temperature/top_p before forwarding to Kimi Code K models VS Code Copilot chat sends temperature:0.1 and top_p:1, which Kimi Code rejects with 400 "invalid temperature: only 1 is allowed for this model". Instead of rewriting to fixed accepted values, remove the fields for Kimi Code K models only, so the server fills in the value each model and mode wants. Scope is narrowed to the Kimi Code membership endpoints (kimi-code presets and api.kimi.com/ai/coding) and K models (kimi-*, kN), so Moonshot pay-as-you-go (api.moonshot.ai/cn) and moonshot-v1-* keep the user temperature. Tests cover the refused Copilot request, absent fields, already-accepted values, Anthropic endpoint, Moonshot pay-as-you-go keeping user temperature, and another provider left untouched. * kimi: drop locked sampling fields on both Kimi platforms, for the models that lock them A review of the last commit found the rewrite missed Moonshot's pay-as-you-go API: kimi-k2.5 and later there lock temperature and top_p the same as Kimi Code's models (400 "invalid temperature: only 1 is allowed for this model", CherryHQ/cherry-studio#19601), so a Copilot user on a Moonshot key with kimi-k2.6 was still refused. The host check is isKimi again — both platforms — and the model check narrows to the ones that lock the fields: kimi-for-coding* and k3* on Kimi Code, kimi-k2.5 and later on either. moonshot-v1-*, kimi-k2-0905-preview, kimi-k2-thinking and kimi-latest take a range and keep the user's values. TestKimiLockedSampling adds Moonshot host cases both ways (kimi-k2.6 loses the fields, kimi-k2-0905-preview keeps 0.1), so swapping the host check between the platforms fails a test, and each case asserts its own upstream body. * kimi: test the locked-sampling boundaries and the k3 and vendor-prefixed names TestKimiLockedSampling now covers the cases a mutation could slip past: Kimi Code's k3 (the bare-k branch), kimi-k2.5 (the minor >= 5 boundary), kimi-k2-thinking keeping its temperature (k2 without a version dot is not locked), and a relay's vendor-prefixed moonshotai/kimi-k2.6 (the vendor strip). Each of the three surviving mutants from review — minor >= 6, no bare-k branch, no vendor strip — now fails its subtest. |
||
|
|
509e8444d1 | gateway: a tool schema with an enum and no type goes to Kimi with the type its values have (#886) — Kimi Code refused a request whose tools had cua-driver's parse_visual_regions, 400 "tools.function.parameters is not a valid moonshot flavored json schema … At path 'properties.options.properties.kinds.anyOf.items': type is not defined": its items were {"enum":["text","icon"]}, and the whole request failed though the tool was never called. To Moonshot and Kimi Code (api.moonshot.ai/.cn, api.kimi.com/.ai, or a moonshot/kimi preset) each schema in the tools with an enum or a const and no type is now given the type its values all have (string, integer, number, boolean), written in place after its brace, through properties, items, anyOf/oneOf/allOf, $defs and the rest; values of mixed types or with a null are left as they were, and other providers are sent the tools unchanged. TestKimiToolEnumTypes fails without the change. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. |