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.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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)
|
||||
})
|
||||
+15
-2
@@ -395,6 +395,10 @@ function foldRoot(root, ps, depth) {
|
||||
return out
|
||||
}
|
||||
|
||||
// what Codex asks an OpenAI provider for with output token replay on
|
||||
// (codex-rs/core/src/client.rs)
|
||||
const OUTPUT_REPLAY = "output.encrypted_content"
|
||||
|
||||
const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v)
|
||||
|
||||
// rewrite leaves out what Grok's backend doesn't take: tools of other
|
||||
@@ -407,9 +411,13 @@ const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v)
|
||||
// encrypted reasoning. A function's parameters with a union at the root
|
||||
// (Codex desktop's codex_app automation_update) are folded to an object,
|
||||
// which Grok turns away otherwise: "tool parameter root must be an object
|
||||
// type" (magpie#1271).
|
||||
// type" (magpie#1271). Codex's output token replay asks for each message's
|
||||
// own sealed copy ("output.encrypted_content" in include), which Grok turns
|
||||
// away: 'Argument not supported: "output.encrypted_content" in "include"
|
||||
// field' (#524). Only that value goes; reasoning.encrypted_content and the
|
||||
// tool-output values xAI documents stay.
|
||||
function rewrite(body, xSearch = false) {
|
||||
if (typeof body !== "string" || (!xSearch && !body.includes('"tools"') && !body.includes('"tool_choice"') && !body.includes('"reasoning"') && !body.includes('"agent_message"'))) return body
|
||||
if (typeof body !== "string" || (!xSearch && !body.includes('"tools"') && !body.includes('"tool_choice"') && !body.includes('"reasoning"') && !body.includes('"agent_message"') && !body.includes(`"${OUTPUT_REPLAY}"`))) return body
|
||||
let m
|
||||
try {
|
||||
m = JSON.parse(body)
|
||||
@@ -475,6 +483,11 @@ function rewrite(body, xSearch = false) {
|
||||
? [{ type: "input_text", text: `${header}\n\n` }, ...it.content] : it.content }
|
||||
})
|
||||
}
|
||||
if (Array.isArray(m.include) && m.include.includes(OUTPUT_REPLAY)) {
|
||||
m.include = m.include.filter((v) => v !== OUTPUT_REPLAY)
|
||||
if (!m.include.length) delete m.include
|
||||
dirty = true
|
||||
}
|
||||
for (const it of Array.isArray(m.input) ? m.input : []) {
|
||||
if (it && it.type === "reasoning" && "content" in it && it.content === null) {
|
||||
delete it.content
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-grok-auth",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"description": "OpenCode provider plugin: Grok (SuperGrok / X Premium+) through the Grok Build CLI's sign-in",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
|
||||
Reference in New Issue
Block a user