Skip to content

fix(codex): inject token saver prompts as instructions - #2508

Open
Jordannst wants to merge 1 commit into
decolua:masterfrom
Jordannst:fix-codex-token-saver-input-content
Open

Jordannst wants to merge 1 commit into
decolua:masterfrom
Jordannst:fix-codex-token-saver-input-content

Conversation

@Jordannst

Copy link
Copy Markdown
Contributor

Summary

Fixes Token Saver/Caveman prompt injection for Codex/OpenAI Responses requests.

When Token Saver injected a system prompt into a Responses-style request with no existing instructions field, it fell back to inserting a chat-style message into input[]:

{ role: "system", content: "..." }

Codex GPT-5.6 rejects that shape because Responses input[] entries must use Responses item/content schemas, so requests failed with:

Unknown parameter: 'input[0].content'

Changes

  • Pass the target request format into injectMessagesSystem.
  • For openai-responses, openai-response, and codex formats, append Token Saver/Caveman prompt text to top-level instructions instead of mutating input[].
  • Preserve existing chat-completions behavior: non-Responses OpenAI-shaped requests still receive a system message in messages[].
  • Add regression coverage for:
    • Responses requests with no existing instructions field.
    • Responses requests with existing instructions.
    • Chat completions messages[] injection behavior.

Verification

npx --yes vitest@4.1.10 run --environment node tests/unit/system-inject.test.js tests/unit/caveman-prompts.test.js

Result:

Test Files  2 passed (2)
Tests       12 passed (12)

Closes #2497

bloodf pushed a commit to bloodf/durindoor that referenced this pull request Jul 10, 2026
…tructions

Ported from decolua/9router#2508 @ 6b2eaf0b40fbe5e4e246e2092c07fa2a0a719764. Routes Codex/OpenAI-Responses token-saver system prompts to the top-level `instructions` field instead of injecting a synthetic system entry into input[], which Codex rejects.
bloodf pushed a commit to bloodf/durindoor that referenced this pull request Jul 10, 2026
…tructions

Ported from decolua/9router#2508 @ 6b2eaf0b40fbe5e4e246e2092c07fa2a0a719764. Routes Codex/OpenAI-Responses token-saver system prompts to the top-level `instructions` field instead of injecting a synthetic system entry into input[], which Codex rejects.
bloodf pushed a commit to bloodf/durindoor that referenced this pull request Jul 10, 2026
…tructions

Ported from decolua/9router#2508 @ 6b2eaf0b40fbe5e4e246e2092c07fa2a0a719764. Routes Codex/OpenAI-Responses token-saver system prompts to the top-level `instructions` field instead of injecting a synthetic system entry into input[], which Codex rejects.
bloodf pushed a commit to bloodf/durindoor that referenced this pull request Jul 10, 2026
…tructions

Ported from decolua/9router#2508 @ 6b2eaf0b40fbe5e4e246e2092c07fa2a0a719764. Routes Codex/OpenAI-Responses token-saver system prompts to the top-level `instructions` field instead of injecting a synthetic system entry into input[], which Codex rejects.
bloodf pushed a commit to bloodf/durindoor that referenced this pull request Jul 10, 2026
…tructions

Ported from decolua/9router#2508 @ 6b2eaf0b40fbe5e4e246e2092c07fa2a0a719764. Routes Codex/OpenAI-Responses token-saver system prompts to the top-level `instructions` field instead of injecting a synthetic system entry into input[], which Codex rejects.
bloodf added a commit to bloodf/durindoor that referenced this pull request Jul 10, 2026
…tructions (#162)

Ported from decolua/9router#2508 @ 6b2eaf0b40fbe5e4e246e2092c07fa2a0a719764. Routes Codex/OpenAI-Responses token-saver system prompts to the top-level `instructions` field instead of injecting a synthetic system entry into input[], which Codex rejects.

Co-authored-by: port-bot <port@local>
@t101804

t101804 commented Jul 13, 2026

Copy link
Copy Markdown

this thing gotta be merged asap

hohaivu added a commit to hohaivu/9router that referenced this pull request Jul 15, 2026
Token Saver/Caveman injected a chat-style {role:"system"} message into
input[] for Responses-style requests with no existing instructions
field. Codex GPT-5.6 rejects that shape ("Unknown parameter:
'input[0].content'"). Append to top-level instructions instead for
openai-responses/openai-response/codex formats; unchanged for
chat-completions.

Closes upstream decolua#2497. Cherry-picked from upstream PR decolua#2508.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dancju

dancju commented Aug 8, 2026 •

Copy link
Copy Markdown

maintainers, merge this please

afandiaziz pushed a commit to afandiaziz/9router that referenced this pull request Aug 9, 2026
29 PR upstream di-cherry-pick (semua masih open upstream per 2026-08-09).
Rincian lengkap + link per PR ada di FORK-CHANGES.md.

P1 skala 2475 koneksi : decolua#2798 decolua#410 decolua#2879 decolua#879 decolua#2997
P2 akurasi token/usage: decolua#2422 decolua#2658 decolua#2762 decolua#2453 decolua#2668 decolua#2361
P3 provider & combo   : decolua#2526 decolua#3125 decolua#1434 decolua#2689 decolua#2439 decolua#2724 decolua#2647 decolua#1805
                        decolua#2909 decolua#2853 decolua#2508 decolua#2928 decolua#2345 decolua#2112 decolua#2786
P4 keamanan           : decolua#1666 decolua#2776

Revert decolua#664: menambah transformRequest kedua di DefaultExecutor sehingga
menimpa yang pertama dan mematikan stream_options/text.format/
injectReasoningContent/stripUnsupportedParams — termasuk PR decolua#3081 yang
sudah dipakai produksi.

Test: 88 gagal / 1783 lulus — nol regresi vs baseline v0.5.50 (88/1656).
hohaivu added a commit to hohaivu/9router that referenced this pull request Aug 14, 2026
Token Saver/Caveman injected a chat-style {role:"system"} message into
input[] for Responses-style requests with no existing instructions
field. Codex GPT-5.6 rejects that shape ("Unknown parameter:
'input[0].content'"). Append to top-level instructions instead for
openai-responses/openai-response/codex formats; unchanged for
chat-completions.

Closes upstream decolua#2497. Cherry-picked from upstream PR decolua#2508.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

GPT 5.6 - Unknown parameter: 'input[0].content

3 participants