Skip to content

fix(devin): handle denied Codex boilerplate and optional history rewrites - #8590

Open
luvs01 wants to merge 5 commits into
lidge-jun:devfrom
luvs01:devin-data-surface-sanitize
Open

luvs01 wants to merge 5 commits into
lidge-jun:devfrom
luvs01:devin-data-surface-sanitize

Conversation

@luvs01

@luvs01 luvs01 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Codex CLI boilerplate can cause Cognition to refuse otherwise valid Devin requests with permission_denied. Add two narrowly matched instruction rewrites and an off-by-default OPENCODEX_DEVIN_SANITIZE_DATA_SURFACES=1 option for histories that quote known trigger phrases.

The option rewrites joined message text, tool-call arguments, image captions and replayed thinking in the outgoing payload. Tool names and call IDs remain unchanged. Rewritten thinking is sent without its stale signature/type; unchanged and signature-only replay retain their original fields. Stored history is unchanged. Exact quoted text may change when opted in, and unsigned replay does not guarantee upstream acceptance.

Local credential-reading diagnostic scripts are excluded from the final diff. Prepared and reviewed first in luvs01#817.

Verification

Current head: 33884d887cc1ebecb3049e8ec87330149df045bb, integrated with upstream dev aa30ea9d5e.

  • Bun 1.4.4: bun test tests/providers/devin-adapter.test.ts tests/providers/devin-chat-wire-fixes.test.ts tests/providers/devin-reasoning-continuation.test.ts tests/providers/devin-anthropic-signature-fallback.test.ts tests/providers/devin-hardening.test.ts tests/providers/devin-image-passthrough.test.ts: 218 pass, 0 fail, 1,647 assertions.
  • bun check --no-script --noEmit: passed, 2,433 files.
  • bun run structure:check, bun run privacy:scan and git diff --check: passed.
  • Current-head upstream CI passed: https://github.com/lidge-jun/opencodex/actions/runs/43181948789 (including changed tests, gates, docs build and smoke checks). Fork CI ran the broader full lane and failed an unchanged GUI target-switch timing assertion (codex-account-pool-target-switch.test.tsx:262, 3 reads expected, 2 observed); that failure is recorded separately and has not been dismissed or rerun.
  • Historical native-session acceptance at b534b8849b: the formerly denied Devin chat completed with HTTP 200 and an OK response. This predates the signature-consistency follow-up and is not evidence for live acceptance of rewritten signed thinking.
  • Full local suite not repeated because of shared Windows disk contention. Earlier test:changed selection was blocked by automatic approval review for unrelated external Google egress; it was not retried through another route. Focused transport tests use mocked network responses. Broader coverage is left to hosted CI.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • New Features
    • Devin requests can optionally rewrite matching text in messages, tool arguments, image captions, and replayed thinking when the setting is exactly "1".
    • Tool names, call IDs, and image data are not rewritten. Signatures are omitted for rewritten thinking and preserved when thinking is unchanged.
  • Documentation
    • Updated Devin adapter guidance to explain the opt-in setting, which data it affects, and its limitations.

The blocklist sanitizer only touched instruction surfaces (tool descriptions, the #2 system prompt); data fields stayed byte-exact, so one quoted trigger phrase anywhere in a long thread history made every later request fail with upstream permission_denied.

New OPENCODEX_DEVIN_SANITIZE_DATA_SURFACES=1 opt-in extends the same rewrites to message text (#3), tool-call arguments (#6.3), image captions (#10.3) and replayed thinking (#11). Identifiers (tool name, tool_call_id) and opaque signature blobs stay byte-exact. Off by default: rewriting literal history changes what the model sees, so refusing stays the default failure.

The permission_denied hint now names the opt-in. Tests pin both modes: data literal by default, rewritten when enabled.
Two more live-isolated triggers in the Codex CLI developer boilerplate: the identity sentence "Codex refers to the open-source agentic coding interface" and the "Don not output ANSI escape codes directly — the CLI renderer applies them" bullet. Both are rewritten meaning-preservingly like the existing entries. Also adds the dump/bisect probe scripts used to isolate the triggers.
Keep reasoning signatures only when the serialized thinking is unchanged.
Preserve signature-only replay and default-off sanitization, and add wire,
authentication and continuity regressions with matching adapter docs.
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Devin adapter adds opt-in rewriting for message text, tool arguments, image captions, and replayed thinking. It enables this behavior only when OPENCODEX_DEVIN_SANITIZE_DATA_SURFACES equals "1". Rewritten thinking is sent without its original signature fields.

Changes: Devin data-surface sanitization

Layer / File(s) Summary
Sanitization behavior
src/adapters/devin/cloud-direct/chat.ts, tests/providers/devin-adapter.test.ts
The adapter adds two Codex phrase rewrites and applies optional sanitization to prompt text, tool arguments, image captions, and replayed thinking. Tool-call names and IDs remain unchanged. Thinking signatures are emitted only when the thinking text is unchanged. Tests cover rewrites and signature handling.
Opt-in wiring and documentation
src/adapters/devin/cloud-direct/chat.ts, docs-site/src/content/docs/reference/adapters.md, structure/providers-and-adapters.md, tests/providers/devin-adapter.test.ts
streamChatEvents enables sanitization only when the environment variable equals "1" and passes the flag into request construction. The documentation describes the option and its scope. An integration-style test checks environment-value handling, request data, and stored history.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant streamChatEvents
  participant buildGetChatMessageRequest
  participant encodeChatMessagePrompt
  streamChatEvents->>buildGetChatMessageRequest: pass sanitizeDataSurfaces
  buildGetChatMessageRequest->>encodeChatMessagePrompt: pass sanitization flag
  encodeChatMessagePrompt->>encodeChatMessagePrompt: rewrite selected data surfaces when enabled
Loading
Merge Risk: Minimal · up to 33884

The change adds an off-by-default option for rewriting history data surfaces in the Devin adapter, leaving default behavior unchanged. No actionable merge-blocking risk remains; translated documentation can be updated as a follow-up.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two main changes: handling denied Codex boilerplate (the two added blocklist rewrite phrases and the denial message update) and the opt-in history rewrites (OPENCODEX_DEVIN_SANITIZ…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two main changes: handling denied Codex boilerplate (the two added blocklist rewrite phrases and the denial message update) and the opt-in history rewrites (OPENCODEX_DEVIN_SANITIZE_DATA_SURFACES). It is specific and matches the raw summary and PR objectives. It is a single sentence of 9 words and omits the signature-dropping behavior, which is expected for a title.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between aa30ea9 and 33884d8.

Files selected for processing: 4

  • docs-site/src/content/docs/reference/adapters.md
  • src/adapters/devin/cloud-direct/chat.ts
  • structure/providers-and-adapters.md
  • tests/providers/devin-adapter.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 12, 2026
@luvs01
luvs01 marked this pull request as ready for review November 12, 2026 08:46

This branch has not been deployed

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant