{"record":{"id":"40d02760fc0400cf","repo":"nikivdev/code","slug":"agent-run-requires-a-non-empty-query","errorCode":null,"errorMessage":"agent run requires a non-empty query","messagePattern":"agent run requires a non-empty query","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai.rs","lineNumber":11303,"sourceCode":"        CodexAgentAction::Show { agent_id } => {\n            let output = run_agent_router_show(&agent_id)?;\n            print!(\"{output}\");\n            if !output.ends_with('\\n') {\n                println!();\n            }\n            Ok(())\n        }\n        CodexAgentAction::Run {\n            path,\n            new_thread,\n            json,\n            agent_id,\n            query,\n        } => {\n            let target_path = resolve_session_target_path(path.as_deref())?;\n            let query_text = query.join(\" \").trim().to_string();\n            if query_text.is_empty() {\n                bail!(\"agent run requires a non-empty query\");\n            }\n            let repo_root = detect_git_root(&target_path).unwrap_or_else(|| target_path.clone());\n            let completed =\n                run_codex_agent_bridge(&agent_id, &target_path, new_thread, &query_text)?;\n            record_run_agent_bridge_activity(&agent_id, &target_path, &repo_root, &completed);\n            if json {\n                println!(\n                    \"{}\",\n                    serde_json::to_string_pretty(&completed)\n                        .context(\"failed to encode codex agent run JSON\")?\n                );\n            } else {\n                print_run_agent_completed_event(&completed);\n            }\n            Ok(())\n        }\n    }\n}","sourceCodeStart":11285,"sourceCodeEnd":11321,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai.rs#L11285-L11321","documentation":"This error is thrown when the `f agent run`-style CLI subcommand is invoked without any effective query text. The command joins the variadic `query` arguments with spaces and trims the result; if the result is empty (no args, or only whitespace), the command refuses to start an agent run. It exists to fail fast before spawning the codex agent bridge.","triggerScenarios":"Calling the agent run subcommand with no positional query words, or with query arguments consisting only of whitespace (e.g. `f <agent> run --agent my-agent \"   \"`).","commonSituations":"Scripting the CLI where a shell variable holding the prompt is empty or unset; quoting mistakes that drop the prompt argument; copy-pasting a command template without filling in the query.","solutions":["Pass a non-empty prompt as positional arguments after the run subcommand","Check that any shell variable used for the prompt is non-empty before invoking","Quote the prompt so whitespace survives shell splitting"],"exampleFix":"// before\nf my-agent run \"$PROMPT\"   # PROMPT is empty -> bail!\n// after\n[ -n \"$PROMPT\" ] && f my-agent run \"$PROMPT\"","handlingStrategy":"validation","validationCode":"let query_text = query.join(\" \").trim().to_string();\nif query_text.is_empty() {\n    eprintln!(\"agent run requires a non-empty query\");\n    std::process::exit(2);\n}","typeGuard":"fn has_query(args: &[String]) -> bool {\n    !args.join(\" \").trim().is_empty()\n}","tryCatchPattern":null,"preventionTips":["Always pass the prompt as quoted positional args","Guard shell variables with ${PROMPT:?unset} before invoking","Add a smoke test asserting the command fails fast on empty query"],"tags":["cli","validation","argument-error"],"backgroundTag":"missing-required-argument","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}