{"record":{"id":"b9f64ee0e4d33268","repo":"zeroclaw-labs/zeroclaw","slug":"grok-cli-extra-args-must-not-include-reserved-flag","errorCode":null,"errorMessage":"grok_cli extra_args must not include reserved flag `{flag}`. ACP transport, prompt, model, session, cwd, and update policy are owned by ZeroClaw.","messagePattern":"grok_cli extra_args must not include reserved flag `(.+?)`\\. ACP transport, prompt, model, session, cwd, and update policy are owned by ZeroClaw\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-providers/src/grok_cli.rs","lineNumber":563,"sourceCode":"    fn normalize_and_validate_extra_args(extra_args: Vec<String>) -> anyhow::Result<Vec<String>> {\n        let extra_args: Vec<String> = extra_args\n            .into_iter()\n            .map(|arg| arg.trim().to_string())\n            .filter(|arg| !arg.is_empty())\n            .collect();\n        let mut index = 0;\n        while index < extra_args.len() {\n            let arg = &extra_args[index];\n            if arg == \"--\" || !arg.starts_with(\"--\") {\n                anyhow::bail!(\n                    \"grok_cli extra_args accepts long flags only and must not include positional arguments\"\n                );\n            }\n            let (flag, has_inline_value) = arg\n                .split_once('=')\n                .map_or((arg.as_str(), false), |(flag, _)| (flag, true));\n            if RESERVED_EXTRA_ARG_FLAGS.contains(&flag) {\n                anyhow::bail!(\n                    \"grok_cli extra_args must not include reserved flag `{flag}`. \\\n                     ACP transport, prompt, model, session, cwd, and update policy are owned by ZeroClaw.\"\n                );\n            }\n            if has_inline_value || VALUELESS_EXTRA_ARG_FLAGS.contains(&flag) {\n                index += 1;\n                continue;\n            }\n            if VALUE_TAKING_EXTRA_ARG_FLAGS.contains(&flag) {\n                let Some(value) = extra_args.get(index + 1) else {\n                    anyhow::bail!(\n                        \"grok_cli extra_args option `{flag}` is missing its value and could consume the provider-owned ACP command\"\n                    );\n                };\n                if value.starts_with('-') {\n                    anyhow::bail!(\n                        \"grok_cli extra_args option `{flag}` must use `--flag=value` when its value starts with `-`\"\n                    );","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-providers/src/grok_cli.rs#L545-L581","documentation":"extra_args may not contain flags from RESERVED_EXTRA_ARG_FLAGS (-p, --model, -m, --cwd, --session-id, --resume, --worktree, 'agent', 'stdio', and the rest): ZeroClaw owns the ACP transport, prompt, model, session, cwd, and update policy, and a duplicate would corrupt the constructed command line.","triggerScenarios":"Adding '--model grok-4', '--cwd /x', '--session-id abc', or literal 'agent stdio' tokens to extra_args; porting a manual grok invocation flag-for-flag.","commonSituations":"Config migration from raw CLI usage; attempts to pin a model or resume a session through extra_args instead of provider fields.","solutions":["Set the model through the provider's model field, cwd through working_directory","Remove reserved tokens from extra_args entirely","Check the reserved list in grok_cli.rs when adding any new flag"],"exampleFix":"# before\nextra_args = [\"--model\", \"grok-4\"]\n\n# after\nmodel = \"grok-4\"   # provider field; extra_args = []","handlingStrategy":"validation","validationCode":"fn is_reserved_extra_arg(flag: &str) -> bool {\n    // mirror RESERVED_EXTRA_ARG_FLAGS from grok_cli.rs\n    [\"-p\", \"--model\", \"-m\", \"--cwd\", \"--session-id\", \"-s\", \"--resume\",\n     \"--continue\", \"agent\", \"stdio\"].contains(&flag)\n}\n\nfn extra_args_safe(args: &[String]) -> bool {\n    args.iter().all(|a| {\n        let flag = a.split('=').next().unwrap_or(a);\n        !is_reserved_extra_arg(flag)\n    })\n}","typeGuard":"fn is_reserved_extra_arg(flag: &str) -> bool {\n    [\"-p\", \"--model\", \"-m\", \"--cwd\", \"--session-id\", \"agent\", \"stdio\"].contains(&flag)\n}","tryCatchPattern":null,"preventionTips":["Configure model via the model field and cwd via working_directory","Do not include the 'agent stdio' subcommand tokens in extra_args","Sync your lint list with RESERVED_EXTRA_ARG_FLAGS when upgrading zeroclaw"],"tags":["rust","zeroclaw","grok-cli","cli-arguments","reserved-flags","configuration"],"backgroundTag":"reserved-cli-flag","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}