Skip to content

feat: automatically enable non-interactive mode for AI agents - #10856

Merged
joehan merged 2 commits into
mainfrom
enable-noninteractive-agent-mode
Aug 5, 2026
Merged

joehan merged 2 commits into
mainfrom
enable-noninteractive-agent-mode

Conversation

@joehan

@joehan joehan commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

This PR automatically sets options.nonInteractive = true when an AI agent is detected in the environment. This makes the CLI more usable for agents by failing fast instead of hanging on prompts.

Evaluation Results

We ran the complete 51-case evaluation suite in google3 (firebase_tools_evals) to compare the baseline (origin/main) against this branch:

Metric Baseline (main) Branch (enable-noninteractive) Change
Pass Rate 51.0% (26/51) 64.7% (33/51) +13.7% (+7 cases)
Input Tokens 7,489.8k 10,413.4k +39.0%
Output Tokens 259.8k 420.6k +61.9%
Total Tokens 7,749.6k 10,834.0k +39.8%
Total Turns 1,553 2,197 +41.5%
Tool Calls 684 838 +22.5%

Note on Token Usage

Automatically enabling non-interactive mode increases token usage and turns because it prevents the agent from hanging on prompts. Instead of waiting and timing out, the agent receives immediate feedback and can use its remaining turns to actively troubleshoot and find alternative non-interactive flags (e.g. appending --project or --non-interactive explicitly). This active recovery is what drove the 13.7% increase in pass rate.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates src/command.ts to import and use the detectAIAgent utility from ./env. It modifies the condition for setting non-interactive mode to automatically enable it if an AI agent is detected (i.e., detectAIAgent() !== 'unknown'). There are no review comments, so I have no feedback to provide.

@joehan
joehan requested a review from yuchenshi July 28, 2026 21:00
@joehan
joehan force-pushed the enable-noninteractive-agent-mode branch 2 times, most recently from 17237cd to 5b87262 Compare July 28, 2026 23:13
Comment thread src/prompt.ts Outdated
opts: BasicOptions<T>,
): { shouldReturn: true; value: T } | { shouldReturn: false; value: undefined } {
if (!opts.nonInteractive) {
if (!opts.nonInteractive && process.env.NON_INTERACTIVE !== "true") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comparing to "true" is safe - but a little ugly. Can we infer the truth-y value just by checking the variable is set? I suppose one could set it to "false" but is that valid, vs unset NON_INTERACTIVE

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, probably should just remove this env var functionality, it was added for testing mostly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a global non-interactive safeguard because many commands (e.g. init) invoke prompt wrappers without explicitly passing the nonInteractive option. Without a global flag, these prompts try to go interactive and hang in non-interactive environments.

However, using process.env is indeed not ideal and prone to test pollution. I have refactored this to use a module-level global variable in src/prompt.ts (managed via exported setNonInteractive helpers) to avoid polluting the environment.

Comment thread src/prompt.ts Resolved
Comment thread src/dataconnect/types.ts Outdated
},
schemaValidation: ds.postgresql.schemaValidation,
},
const postgresql: PostgreSql = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated? could move to second PR

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wtf, this definitely was not intended to be part of the PR. removing

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reverted the changes in src/dataconnect/types.ts as they were unintended for this PR.

@joehan
joehan force-pushed the enable-noninteractive-agent-mode branch from 05ad6de to aa39f48 Compare August 5, 2026 18:11
@joehan
joehan enabled auto-merge (squash) August 5, 2026 21:30
@joehan
joehan merged commit 5ab9db5 into main Aug 5, 2026
52 of 53 checks passed
@joehan
joehan deleted the enable-noninteractive-agent-mode branch August 5, 2026 21:39
yuichi0301 pushed a commit to yuichi0301/firebase-tools that referenced this pull request Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants