nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Codex provider sends the unscrubbed system prompt as `instructions`, bypassing privacy scrubbing

Open addyCooks opened this issue 2 weeks ago • 0 comments

Description

With privacy scrubbing on, the system prompt is scrubbed before the request is built. The Codex provider options are built from the unscrubbed prompt, so the instructions field of a ChatGPT/Codex request carries the original text while the input items are scrubbed.

Environment

  • OS: Windows 11 Home 10.0.26300
  • Node version: v22.22.3
  • Nanocoder version: 1.32.0 (built from main at 5df35b3a)
  • Provider: ChatGPT/Codex (sdkProvider: "chatgpt-codex"), pointed at a local fake backend
  • Model: gpt-5-codex

Steps to Reproduce

  1. Run a local HTTP server that records the request body and answers 500.
  2. Put a fake credential for the provider name in $NANOCODER_CONFIG_DIR/codex-credentials.json: {"codexmock": {"accessToken": "tok", "accountId": "acc"}}.
  3. Create the client: AISDKClient.create({name: 'codexmock', sdkProvider: 'chatgpt-codex', models: ['gpt-5-codex'], config: {baseURL: 'http://127.0.0.1:<port>', apiKey: 'x'}}).
  4. Call client.chat([{role: 'system', content: 'You are helpful. Internal contact: [email protected]'}, {role: 'user', content: 'My email is [email protected]'}], {}, callbacks, undefined, {privacyEnabled: true, privacySessionMapRef: {current: {}}}).
  5. Read the recorded request body.

Expected Behavior

instructions contains the scrubbed text ("... Internal contact: «Email_1»"), like the input items.

Actual Behavior

instructions contains the original email address.

Logs/Screenshots

instructions: You are helpful. Internal contact: [email protected]
input: [{"role":"developer","content":"You are helpful. Internal contact: «Email_1»"},
        {"role":"user","content":[{"type":"input_text","text":"My email is «Email_2»"}]}]

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder (main)

Suggested fix:

  • source/ai-sdk-client/chat/chat-handler.ts:321-325: buildProviderOptions(providerConfig, systemContent, ...) is passed systemContent (the text before scrubbing). Pass finalSystemContent (set at lines 234-246) instead.
  • Add a test that checks instructions matches the scrubbed system text when privacy is on.
  • The system prompt can hold AGENTS.md content and project context, so this sends text the user asked to keep local.

addyCooks avatar Nov 16 '26 09:11 addyCooks