Skip to content

fix: re-inject the client's openai system around the kernel hoist (0.0.37) - #193

Closed
ranxianglei wants to merge 2 commits into
masterfrom
2026-08-22_openai-system-hoist
Closed

fix: re-inject the client's openai system around the kernel hoist (0.0.37)#193
ranxianglei wants to merge 2 commits into
masterfrom
2026-08-22_openai-system-hoist

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Symptom

The kernel (PR ranxianglei/acp-kernel#120, released 0.0.37) hoists the contiguous leading system/developer prefix OUT of the openai fold space: system content is host runtime state and must not feed ids/fingerprints, and a compression covering it used to delete the model's system prompt from every rebuilt payload.

Consequence for the proxy: after upgrading the kernel alone, openaiToCore's msgs no longer carry the system at all — without this PR every forwarded payload and every compress-loop round would silently drop the client's system prompt.

Fix

  • prepareOpenai captures systemText from openaiToCore and re-injects it into every rebuilt payload (client system first, compress prompt after — preserves the prefix-cache-anchor ordering)
  • Prepared.openaiSystemText flows into pickAdaptercreateOpenaiAdapter(requestBody, clientSystem) so compress-loop rounds re-inject it too, mirroring the anthropic adapter's anthropicSystem path
  • loop adapter buildRequest injects [clientSystem, compressPrompt] (empty parts filtered)

Note the proxy never had the restart-fingerprint failure (MITM sees the real wire every round) but DID inherit the compression-eats-system bug — and would lose system entirely on 0.0.37 without this change.

Tests

  • 512 pass / 0 fail; round-trip tests updated to the hoist contract (leading prefix hoisted + mid-conversation system/developer still round-trips via originalRole)
  • acp-kernel 0.0.37 from npm

…0.37)

The kernel hoists the contiguous leading system/developer prefix out of
the openai fold space (system content is host runtime state - it must not
feed ids/fingerprints, and a compression covering it used to delete the
model's system prompt from every rebuilt payload). The proxy must now
carry it around the fold:

- prepareOpenai captures systemText from openaiToCore and re-injects it
  (client system first, compress prompt after) into every rebuilt payload
- Prepared.openapiSystemText flows into pickAdapter so compress-loop
  rounds re-inject it too, mirroring the anthropic adapter's
  anthropicSystem path
- createOpenaiAdapter gains a clientSystem param
@ranxianglei

Copy link
Copy Markdown
Owner Author

防止模型擅自合并,先关闭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant