google-gemini/gemini-cli · error · FatalInputError
Exiting due to an error processing the @ command.
Error message
Exiting due to an error processing the @ command.
What it means
Same condition as error 102 but in the agent-session non-interactive path (nonInteractiveCliAgentSession). When no pre-formed query exists, handleAtCommand is invoked and, on error or empty processedQuery, a FatalInputError (exit code 42) is thrown. The message is a fallback; the real cause was logged by handleAtCommand.
Source
Thrown at packages/cli/src/nonInteractiveCliAgentSession.ts:286
);
if (slashCommandResult) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
query = slashCommandResult as Part[];
}
}
if (!query) {
const { processedQuery, error } = await handleAtCommand({
query: input,
config,
addItem: (_item, _timestamp) => 0,
onDebugMessage: () => {},
messageId: Date.now(),
signal: abortController.signal,
escapePastedAtSymbols: false,
});
if (error || !processedQuery) {
throw new FatalInputError(
error || 'Exiting due to an error processing the @ command.',
);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
query = processedQuery as Part[];
}
// Emit user message event for streaming JSON
if (streamFormatter) {
streamFormatter.emitEvent({
type: JsonStreamEventType.MESSAGE,
timestamp: new Date().toISOString(),
role: 'user',
content: input,
});
}
// Create LegacyAgentSession — owns the agentic loopView on GitHub (pinned to 5024443c72)
Solutions
- Inspect the prior debug/error log line emitted by handleAtCommand for the concrete reason.
- Confirm the @-target exists and is within the workspace root / allowed extensions.
- Validate MCP connectivity for @-resources and agent registration for @-agents.
- Drop the @-include or supply a resolvable path.
Example fix
# before gemini -p "@docs/missing.md summarize" # after gemini -p "@docs/existing.md summarize"
Defensive patterns
Strategy: try-catch
Validate before calling
import fs from 'node:fs';
import path from 'node:path';
function preflightAtIncludes(input: string, root: string): string[] {
const bad: string[] = [];
for (const m of input.matchAll(/@([\w./\\-]+\.[\w]+)/g)) {
if (!fs.existsSync(path.resolve(root, m[1]))) bad.push(m[1]);
}
return bad;
} Type guard
function hasResolvedQuery(r: { processedQuery: unknown; error?: string }): boolean {
return Array.isArray(r.processedQuery) && r.processedQuery.length > 0 && !r.error;
} Try / catch
try {
await runAgentSession(input);
} catch (e) {
if (e instanceof FatalInputError && /@ command/.test(e.message)) {
// exit code 42: handleAtCommand already logged the concrete cause
}
throw e;
} Prevention
- Resolve @-file paths against the workspace root before sending non-interactive prompts.
- Confirm MCP resources/agents referenced via @ are registered and reachable.
- Run such prompts interactively first to surface resolution errors with full context.
When it happens
Trigger: nonInteractiveCliAgentSession invokes handleAtCommand with the user input; it returns { processedQuery: null, error } or { processedQuery: undefined } because a file/resource/agent @-include could not be resolved.
Common situations: Using `gemini -p` with an @-file that does not exist, is outside the workspace, or references an unavailable MCP resource/agent.
Related errors
- Exiting due to an error processing the @ command.
- Operation cancelled.
- Reached max session turns for this session. Increase the num
- Exiting due to command result that is not supported in non-i
- Workspace path ${resolvedPath} does not exist
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/7f9659b70c10f4c6.
Report an issue: GitHub.