Repository navigation
feat: automatically enable non-interactive mode for AI agents - #10856
Conversation
There was a problem hiding this comment.
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.
17237cd to
5b87262
Compare
| opts: BasicOptions<T>, | ||
| ): { shouldReturn: true; value: T } | { shouldReturn: false; value: undefined } { | ||
| if (!opts.nonInteractive) { | ||
| if (!opts.nonInteractive && process.env.NON_INTERACTIVE !== "true") { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Honestly, probably should just remove this env var functionality, it was added for testing mostly.
There was a problem hiding this comment.
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.
| }, | ||
| schemaValidation: ds.postgresql.schemaValidation, | ||
| }, | ||
| const postgresql: PostgreSql = { |
There was a problem hiding this comment.
unrelated? could move to second PR
There was a problem hiding this comment.
Oh wtf, this definitely was not intended to be part of the PR. removing
There was a problem hiding this comment.
I have reverted the changes in src/dataconnect/types.ts as they were unintended for this PR.
05ad6de to
aa39f48
Compare
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:main)enable-noninteractive)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
--projector--non-interactiveexplicitly). This active recovery is what drove the 13.7% increase in pass rate.