@@ -505,9 +505,34 @@ const MAX_TOOL_DESC_LEN = 6998;
505505 * Cognition-specific constraint alongside the length limit above; if
506506 * Cognition adds more blocklisted phrases, extend this table and add a
507507 * regression test in tests/devin-adapter.test.ts.
508+ *
509+ * Not every entry is matched the same way. The Claude Code phrase above is
510+ * case-sensitive and whitespace-exact, but the two Codex entries below are
511+ * not: against a live account, lowercasing the first word and doubling an
512+ * interior space both still produced `permission_denied`, while changing any
513+ * single word passed. So those two match case-insensitively with flexible
514+ * whitespace and an optional comma, and the rewrite swaps only the leading
515+ * verb — the smallest edit measured to clear the filter.
516+ *
517+ * These two sentences are Codex's own built-in `exec_command` and
518+ * `write_stdin` descriptions, verbatim. Every Codex turn carries them, so
519+ * before this table knew about them the cloud refused literally every request
520+ * from a Codex client — a bare "hi" included — while the same account
521+ * answered a hand-built request with an ordinary shell tool. The visible
522+ * symptom was the adapter's own blocklist message pointing back at this
523+ * table, which is why they are named here rather than left to the next person
524+ * to re-bisect.
508525 */
509526const COGNITION_BLOCKLIST_REWRITES : ReadonlyArray < [ RegExp , string ] > = [
510527 [ / \b T a k e s a t a s k _ i d p a r a m e t e r i d e n t i f y i n g t h e t a s k \b / g, "Accepts a task_id parameter identifying the task" ] ,
528+ [
529+ / \b R u n s \s + a \s + c o m m a n d \s + i n \s + a \s + P T Y , ? \s + r e t u r n i n g \s + o u t p u t \s + o r \s + a \s + s e s s i o n \s + I D \s + f o r \s + o n g o i n g \s + i n t e r a c t i o n \b / gi,
530+ "Executes a command in a PTY, returning output or a session ID for ongoing interaction" ,
531+ ] ,
532+ [
533+ / \b W r i t e s \s + c h a r a c t e r s \s + t o \s + a n \s + e x i s t i n g \s + u n i f i e d \s + e x e c \s + s e s s i o n \s + a n d \s + r e t u r n s \s + r e c e n t \s + o u t p u t \b / gi,
534+ "Sends characters to an existing unified exec session and returns recent output" ,
535+ ] ,
511536] ;
512537
513538function sanitizeToolDescriptionForCognition ( description : string ) : string {
@@ -1203,6 +1228,11 @@ export async function* streamChatEvents(req: CloudChatRequest): AsyncGenerator<C
12031228 `Cognition denied this request (permission_denied). If tool descriptions ` +
12041229 `are present, a blocklisted phrase may have triggered this — see the ` +
12051230 `COGNITION_BLOCKLIST_REWRITES table in cloud-direct/chat.ts. ` +
1231+ // Keep the cloud's own sentence. Replacing it outright is what made the
1232+ // two Codex entries in that table expensive to find: the message named
1233+ // the table but dropped the only text that could have said whether this
1234+ // was a phrase match at all.
1235+ `(cloud message: ${ trailerError . message } ) ` +
12061236 `(cloud trace ID: ${ trailerError . traceId ?? 'n/a' } )` ;
12071237 throw new CloudChatError ( enriched , trailerError . code , trailerError . traceId ) ;
12081238 }
0 commit comments