Files
plugins/packages/grok/include.test.mjs
T
yetone 254c3e7aef grok 0.2.3: Codex's output.encrypted_content is left out of include (#524)
Codex asks an OpenAI-named provider for output token replay with
include ["reasoning.encrypted_content", "output.encrypted_content"]
(codex-rs/core/src/client.rs). Grok answers 400 'Argument not
supported: "output.encrypted_content" in "include" field'. rewrite()
now drops that one value (and include when nothing is left), and its
pre-filter also opens a body that names it, so an include-only body is
no longer passed through untouched. reasoning.encrypted_content and the
tool-output values xAI's docs list stay; store is not touched (Grok
takes it).

Tests: packages/grok/include.test.mjs, from the reporter's two bodies
and Codex's include. Red on the old index.mjs (4 of 5; the 5th checks
that accepted values stay). Broken by hand: without the pre-filter
change the include-only case is red.
Run on mote: HOME=$(mktemp -d) bun test (3782 pass, 0 fail) and
bun scripts/check.mjs (exit 0).
Not tried: a real Grok account; no Codex turn sent through Grok.
Sealed copies an OpenAI model wrote earlier in a thread (encrypted_content
on a message) are not stripped here; magpie's forVendor takes those out
before a non-OpenAI provider.
2026-10-30 18:45:39 +08:00

35 lines
1.5 KiB
JavaScript

import { noRealGrok } from "./nocli.mjs"
import { expect, test } from "bun:test"
import { _internal } from "./index.mjs"
noRealGrok()
// #524: Grok answers 400 'Argument not supported: "output.encrypted_content"
// in "include" field'. Codex asks for it beside reasoning.encrypted_content
// when output token replay is on (codex-rs/core/src/client.rs).
const send = (body, search = false) => JSON.parse(_internal.rewrite(JSON.stringify(body), search))
test("an include-only body loses output.encrypted_content (reporter's case 1)", () => {
expect(send({ model: "grok-4.7", include: ["output.encrypted_content"] })).toEqual({ model: "grok-4.7" })
})
test("a body with tools loses it too (reporter's case 2)", () => {
expect(send({ model: "grok-4.7", tools: [], include: ["output.encrypted_content"] })).toEqual({ model: "grok-4.7", tools: [] })
})
for (const search of [false, true]) {
test(`Codex's include keeps reasoning.encrypted_content (x_search ${search})`, () => {
const sent = send({
model: "grok-4.7", input: "hi", store: false, stream: true, reasoning: { effort: "medium" },
include: ["reasoning.encrypted_content", "output.encrypted_content"],
}, search)
expect(sent.include).toEqual(["reasoning.encrypted_content"])
expect(sent.store).toBe(false)
})
}
test("values Grok takes are left as sent", () => {
const body = JSON.stringify({ model: "grok-4.7", input: "hi", include: ["reasoning.encrypted_content", "web_search_call.action.sources"] })
expect(_internal.rewrite(body)).toBe(body)
})