{"record":{"id":"0229fa8bc0527f09","repo":"can1357/oh-my-pi","slug":"agents-must-be-a-positive-integer-0229fa","errorCode":null,"errorMessage":"--agents must be a positive integer","messagePattern":"--agents must be a positive integer","errorType":"validation","errorClass":"CliUsageError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/commands/compress.ts","lineNumber":33,"sourceCode":"\t\trounds: Flags.integer({ char: \"r\", description: \"Maximum drafts per file before giving up\", default: 3 }),\n\t\tagents: Flags.integer({ char: \"n\", description: \"Files compressed concurrently\", default: 4 }),\n\t\tmodel: Flags.string({ char: \"m\", description: \"Model selector\" }),\n\t};\n\n\tstatic examples = [\n\t\t\"omp compress prompts/tools/read.md\",\n\t\t\"omp compress notes.md -o notes.compressed.md\",\n\t\t\"omp compress 'src/prompts/**/*.md' -i\",\n\t\t\"omp compress a.md b.md c.md -i -n 8\",\n\t\t\"omp compress spec.md -r 5 -m opus\",\n\t];\n\n\tasync run(): Promise<void> {\n\t\tconst { args, flags } = await this.parse(Compress);\n\t\tconst files = args.files ?? [];\n\t\tif (files.length === 0) throw new CliUsageError(\"compress requires at least one file or glob pattern\");\n\t\tif (flags.rounds <= 0) throw new CliUsageError(\"--rounds must be a positive integer\");\n\t\tif (flags.agents <= 0) throw new CliUsageError(\"--agents must be a positive integer\");\n\t\tif (flags.inPlace && flags.out) throw new CliUsageError(\"--in-place and --out are mutually exclusive\");\n\t\tconst result = await runCompressCommand({\n\t\t\tfiles,\n\t\t\tmodel: flags.model,\n\t\t\tmaxRounds: flags.rounds,\n\t\t\tconcurrency: flags.agents,\n\t\t\toutput: flags.out,\n\t\t\tinPlace: flags.inPlace,\n\t\t});\n\t\tawait postmortem.quit(result.exitCode);\n\t}\n}\n","sourceCodeStart":15,"sourceCodeEnd":46,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/commands/compress.ts#L15-L46","documentation":"Same validation as the cleanse command: omp compress runs its work across --agents concurrent agents, and only positive integers are valid concurrency. The check happens in run() before any files are processed.","triggerScenarios":"'omp compress spec.md --agents 0' or '--agents -1'; --agents sourced from an unset environment variable or a CI matrix value of 0.","commonSituations":"Dynamic concurrency computed as 0 when no workers are configured; typos; template placeholders left unfilled in CI pipelines.","solutions":["Pass a positive integer, e.g. --agents 12","Omit --agents to use the default concurrency","Guard the computed value: Math.max(1, computedAgents)"],"exampleFix":"// before\nconst agents = Number(process.env.AGENTS ?? 0); // 0 when unset\nomp compress spec.md --agents ${agents}\n// after\nconst agents = Math.max(1, Number(process.env.AGENTS ?? 4));","handlingStrategy":"validation","validationCode":"const agents = Math.max(1, Number(process.env.AGENTS ?? 4));\nif (!Number.isInteger(agents)) throw new Error('agents must be an integer');","typeGuard":"function isPositiveInt(n) { return typeof n === 'number' && Number.isInteger(n) && n > 0; }","tryCatchPattern":"try {\n  await Compress.run(['--agents', String(agents)]);\n} catch (err) {\n  if (err instanceof CliUsageError && err.message.includes('--agents')) {\n    console.error(`Invalid --agents: ${agents}`);\n    process.exitCode = 1;\n  } else throw err;\n}","preventionTips":["Default unset env-driven counts to a positive value","Never encode 'disabled' as 0 for concurrency flags","Sanity-check CI matrix values feeding the flag"],"tags":["cli","usage","validation"],"backgroundTag":"invalid-cli-flag-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}