Skip to content

Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.

TypeScript

fix(byoa): drop the codex config field that aborted every turn

yetone5571892390a6
diff --git a/server/src/__tests__/agents-computer-codex-config.test.ts b/server/src/__tests__/agents-computer-codex-config.test.ts
new file mode 100644
index 0000000..7252cee
--- /dev/null
+++ b/server/src/__tests__/agents-computer-codex-config.test.ts
@@ -0,0 +1,66 @@
+/**
+ * What Cumora sends codex as its sandbox profile, and what it says when the
+ * installed codex refuses it.
+ *
+ * On 2026-09-01 every codex turn in 103 workspaces (299 agents) failed for six
+ * hours. Production carried two distinct rejections:
+ * 78,445 × unknown configuration field `projects."<agent home>"`
+ * 8,372 × invalid type: string "{:minimal=read,:workspace_roots={.=write}}",
+ * expected struct FilesystemPermissionsToml in `permissions`
+ * The first is a field codex does not have; it aborted codex before startup, so
+ * it never restricted anything and is gone. The second was cmd.exe eating the
+ * quotes inside an inline TOML table and is fixed separately (resolveCodexSpawn).
+ *
+ * Run: node --import tsx --test server/src/__tests__/agents-computer-codex-config.test.ts
+ */
+import { test, afterEach } from 'node:test'
+import assert from 'node:assert/strict'
+
+process.env.CUMORA_RUNTIME_CLIENT = 'http'
+process.env.OPENAI_API_KEY ??= 'test-key'
+
+const {
+ noteCodexConfigRejection, codexProfileIsRejected, resetCodexProfileRejection,
+} = await import('../agents/computer/engine.js')
+
+afterEach(() => { resetCodexProfileRejection() })
+
+test('the exact production rejections are recognised', () => {
+ const seen: string[] = []
+ const real = 'local codex failed (exit 1): process exited with code 1 Error loading config.toml: unknown configuration field `projects."<agent home>"` in -c/--config override'
+ assert.equal(noteCodexConfigRejection(real, (l) => seen.push(l)), true)
+ assert.equal(codexProfileIsRejected(), true)
+ // Name Cumora as the author — the raw codex error never does, which is why
+ // this took six hours to reach.
+ assert.match(seen[0] ?? '', /Cumora passes via -c/)
+ // Give the operator a way out, not just a diagnosis.
+ assert.match(seen[0] ?? '', /CUMORA_BYOA_ALLOW_UNSANDBOXED=1/)
+ // And keep what codex actually said, or there is nothing to report upstream.
+ assert.match(seen[0] ?? '', /unknown configuration field/)
+})
+
+test('the inline-table type error is recognised too', () => {
+ const real = 'Error loading config.toml: invalid type: string "{:minimal=read,:workspace_roots={.=write}}", expected struct FilesystemPermissionsToml in `permissions`'
+ assert.equal(noteCodexConfigRejection(real, () => {}), true)
+})
+
+test('it says this once per daemon, not once per failed turn', () => {
+ const seen: string[] = []
+ const err = 'Error loading config.toml: unknown configuration field `projects."x"`'
+ assert.equal(noteCodexConfigRejection(err, (l) => seen.push(l)), true)
+ assert.equal(noteCodexConfigRejection(err, (l) => seen.push(l)), false)
+ assert.equal(seen.length, 1, 'a 20k-failures-per-hour loop must not log 20k times')
+})
+
+test('ordinary engine failures are left alone', () => {
+ for (const err of [
+ undefined,
+ '',
+ 'local codex failed (exit 1): Not logged in · Please run /login',
+ 'local codex failed (exit 126): No version is set for command codex',
+ 'engine turn error (error_during_execution): see log',
+ ]) {
+ assert.equal(noteCodexConfigRejection(err, () => {}), false, `should ignore: ${err}`)
+ assert.equal(codexProfileIsRejected(), false)
+ }
+})
diff --git a/server/src/__tests__/agents-computer-engine.test.ts b/server/src/__tests__/agents-computer-engine.test.ts
index d788633..ed52c22 100644
--- a/server/src/__tests__/agents-computer-engine.test.ts
+++ b/server/src/__tests__/agents-computer-engine.test.ts
@@ -397,7 +397,12 @@ test('Codex one-shot paths send prompts through stdin', async () => {
assert.equal(runCapture.argv?.some((arg) => arg.includes(`${join(root, 'private-ipc', 'responses')}"="write`)), false)
assert.ok(runCapture.argv?.includes('web_search="disabled"'))
assert.ok(runCapture.argv?.includes('features.hooks=false'))
- assert.ok(runCapture.argv?.includes(`projects.${JSON.stringify(home)}.trust_level="untrusted"`))
+ // Never send `projects.<path>.trust_level`: codex has no such configuration
+ // field and rejects the whole invocation over it — 78,445 failed turns in six
+ // hours across 103 workspaces, on every codex version and both platforms.
+ // This assertion used to REQUIRE the flag; it pinned an override that had
+ // never been run against a real codex.
+ assert.equal(runCapture.argv?.some((arg) => arg.startsWith('projects.')), false)
assert.ok(runCapture.argv?.some((arg) =>
arg.startsWith('mcp_servers.cumora={')
&& arg.includes(`command=${JSON.stringify(process.execPath)}`)
diff --git a/server/src/agents/computer/engine.ts b/server/src/agents/computer/engine.ts
index 5640c69..ba4774e 100644
--- a/server/src/agents/computer/engine.ts
+++ b/server/src/agents/computer/engine.ts
@@ -1650,6 +1650,38 @@ function codexToolEnvironmentArgs(args: { home: string; env: NodeJS.ProcessEnv }
return ['-c', `shell_environment_policy.set={${entries.join(',')}}`]
}
+/** Codex rejects the whole invocation when any `-c` override fails to load, and
+ * the resulting error names `config.toml` without ever mentioning that Cumora
+ * authored that config — which is how 103 workspaces spent six hours looking at
+ * agents that would not answer, with no way to reach the cause.
+ *
+ * Say it once per daemon: name Cumora as the author, quote what codex actually
+ * said so it can be reported upstream, and point at the documented escape
+ * hatch. Deliberately does NOT downgrade on its own — the only fallback
+ * available is the historical `--dangerously-bypass-approvals-and-sandbox`, and
+ * trading the sandbox for availability is a maintainer's decision. */
+const CODEX_CONFIG_REJECTED_RE = /Error loading config\.toml|unknown configuration field|expected struct \w+PermissionsToml/i
+
+let codexProfileRejected = false
+
+export function codexProfileIsRejected(): boolean {
+ return codexProfileRejected
+}
+
+/** Test seam. */
+export function resetCodexProfileRejection(): void {
+ codexProfileRejected = false
+}
+
+export function noteCodexConfigRejection(err: string | undefined, onLog?: (line: string) => void): boolean {
+ if (!err || codexProfileRejected || !CODEX_CONFIG_REJECTED_RE.test(err)) return false
+ codexProfileRejected = true
+ const hint = `[codex] the installed codex rejected the sandbox profile Cumora passes via -c. Every turn on this machine fails until this is resolved. Set ${ALLOW_UNSANDBOXED_BYOA_ENV}=1 on the daemon to run with the historical unsandboxed flags, or report the codex version. Codex said: ${err.slice(0, 300)}`
+ onLog?.(hint)
+ console.warn(hint)
+ return true
+}
+
function codexSecureExecArgs(args: { home: string; env: NodeJS.ProcessEnv }, readOnly = false): string[] {
const workspaceAccess = readOnly ? 'read' : 'write'
const filesystemEntries = [
@@ -1666,10 +1698,15 @@ function codexSecureExecArgs(args: { home: string; env: NodeJS.ProcessEnv }, rea
'-c', 'features.remote_plugin=false',
'-c', 'features.multi_agent=false',
'-c', 'features.shell_snapshot=false',
- // Untrusted projects skip project-local config, hooks, and rules. This is a
- // CLI override (highest precedence), so a model cannot plant a more
- // privileged .codex layer for the next one-shot wake.
- '-c', `projects.${tomlString(args.home)}.trust_level="untrusted"`,
+ // NOTE: a `projects.<path>.trust_level="untrusted"` override used to sit
+ // here. Codex has no such configuration field and rejected the entire
+ // invocation over it — `unknown configuration field \`projects."…"\`` — on
+ // every version seen in the field (0.139 through 0.151) and on both
+ // platforms: 78,445 failed turns in six hours across 103 workspaces, 84% of
+ // all codex failures. Because it aborted codex before startup it never
+ // restricted anything, so removing it gives up no protection that was ever
+ // in effect; `exec --ignore-user-config --ignore-rules` below already
+ // excludes project-local config, hooks and rules.
...codexToolEnvironmentArgs(args),
]
if (!readOnly) {
@@ -2120,6 +2157,12 @@ class CodexAdapter implements EngineAdapter {
const model = args.model ? ['--model', args.model] : []
const { command, shell, argsPrefix } = resolveCodexSpawn()
return spawnEngine(command, [...argsPrefix, ...base, ...model, '-'], args, { shell, stdinText: args.prompt })
+ .then((res) => {
+ // A rejected -c override aborts codex before it reads the prompt, so the
+ // turn fails with a config error that never mentions Cumora. Say it once.
+ noteCodexConfigRejection(res.error, args.onLog)
+ return res
+ })
}
startSession(args: EngineSessionArgs): EngineSession | null {