You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support Pi extra arguments in automations - #37320
A scheduled Pi task can choose its own model and thinking level without changing the defaults for every Pi session.
What Changed
Accept Pi --model and --thinking as extra arguments for fresh automation sessions, including --option=value input, and validate thinking levels against the existing Pi level list.
Replace the corresponding host defaults; a provider-qualified model also removes a conflicting host --provider, while a bare model or a matching provider keeps it.
Drop an inline Pi API key when switching providers, and refuse model overrides when its provider is unknown or the key appears in a custom command.
Protect option values and -- boundaries when merging arguments, and document how to qualify gateway model IDs containing /.
Add coverage for saved validation, launch planning, provider conflicts, and POSIX/PowerShell/cmd argument round trips.
Why
Pi previously failed the existing extra-argument allowlist even though these options are safe model-selection settings. Reusing the existing validation and launch path preserves the fresh-session and safety restrictions. Reconciling the provider is necessary because Pi restricts model lookup when --provider is present.
No before/after screenshot captured. The existing Extra arguments field becomes enabled for Pi; validation and launch behavior are covered by automated tests.
Testing
Manually tested the complete automation flow in the desktop UI.
Automated tests added/updated.
The user tested a local macOS build with PR 7cf8fd8 on upstream 94f2be1, creating or editing and running an automation in the desktop UI and confirming both Pi model and thinking options took effect.
The latest PR commit 0449223 was simulated against upstream b49a019: the resulting tree passed 531 focused tests under Node and 421 startup tests under Bun, including inline API-key security cases.
pnpm check:changed --base=b49a019e87f85746d941e5c05c5056a2d4a5289c --maxWorkers=1 --timeout=2 passed 20 of 21 checks, including typechecks, lint and formatting; the broad related-unit-test selection hit the two-minute timeout. It is not a full passing run.
A previous broader local run was stopped after 49,703 passes and 11 cross-version failures; some required unavailable historical tags or checkouts, and others were assertion failures. That run is not passing evidence.
POSIX, PowerShell and cmd argument round trips are automated; Linux, Windows and live SSH hosts were not manually exercised.
Risk
Level: Medium. Provider-qualified Pi models can select a different provider, so gateway IDs must include the gateway prefix. A provider change drops a default inline API key; unknown key ownership or a key in a custom command causes the override to be refused. Configure credentials in Pi per provider. Existing saved extras and older paired/remote hosts keep the existing compatibility checks; no data migration is performed. A plain revert restores the previous behavior, but saved Pi extras would then be rejected until removed or the fix restored.
AI Disclosure
Developed and updated with assistance from the Pi coding agent using openai-codex/gpt-6.1-terra; the PR also received an automated CodeRabbit review.
Review
Reviewed the actual Pi model resolver, the shared merge callers, shell round trips, and provider-conflict behavior.
Agent skill upstream boundary
Not applicable; this change copies or mechanically translates no upstream skill-installer source.
Notes
Input allowlisting, shell quoting, fresh-session validation, and remote compatibility remain in the existing shared paths. No platform-specific execution behavior or mobile protocol was added.
Checklist
This PR is small and focused
I explained what changed and why
I stated the risk and rollback behavior
Before/after visual proof attached for the Pi input becoming enabled
Self-reviewed for correctness, security, and performance
Cross-platform and SSH/remote impact considered
Full pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (the focused changed gate is recorded above; upstream CI still needs to run)
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Walkthrough
Automation extra arguments now support Pi’s --model and --thinking options. The parser recognizes Pi options that take values, and extra values replace matching host defaults. A provider-prefixed model can also remove a conflicting host-default provider. Tests cover supported arguments, rejection cases, and startup-plan output. Documentation now lists Pi as supported and describes provider selection. Existing restrictions, including incompatibility with --reuse-session, remain documented.
Severity of issue fixed: Medium
Merge Risk: Minimal · up to 04492
The previously identified thinking-level and credential-handling issues are addressed. No actionable merge-blocking risk remains after normal checks.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title "Support Pi extra arguments in automations" matches the main change: the PR lets fresh Pi automation sessions accept --model and --thinking as extra arguments. It is specific and short, and …
Description check
The description follows the repository template in structure and is largely complete. It has an ELI5 section, a What Changed list, a Why section, a Linked Issue (Fixes #37357), Visual Proof with a rea…
Linked Issues check
Issue #37357 requires fresh Pi automations to accept and apply supported --model and --thinking arguments. The PR adds Pi to the extra-argument allowlist. It validates --thinking against `PI_THI…
Out of Scope Changes check
The changes stay connected to issue #37357. The allowlist, Pi argument parsing, thinking-level validation, default reconciliation, provider conflict handling, API-key protection, startup-command handl…
Docstring Coverage
Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Full details: Title check
Explanation
The title "Support Pi extra arguments in automations" matches the main change: the PR lets fresh Pi automation sessions accept --model and --thinking as extra arguments. It is specific and short, and it names the feature area (automations) and the agent (Pi). It does not list every detail, which is expected.
Full details: Description check
Explanation
The description follows the repository template in structure and is largely complete. It has an ELI5 section, a What Changed list, a Why section, a Linked Issue (Fixes #37357), Visual Proof with a reason for no screenshot, Testing with manual and automated results, a Risk section with level Medium and rollback behavior, an AI Disclosure, a Review section, the upstream boundary checkbox, Notes, and a Checklist. Some gaps remain. The Visual Proof section is N/A-style but the checklist still lists the Pi input visual proof as unchecked, which is inconsistent. The Testing section mixes a partial 'pnpm check:changed' run with the full checklist item that remains unchecked, and the test counts differ from the objectives (531 vs 513 focused tests, 421 vs 403 startup tests). The Risk section does not say which provider change or API-key behavior applies to existing saved extras in detail. These issues are non-critical, so the description is mostly complete.
Full details: Linked Issues check
Explanation
Issue #37357 requires fresh Pi automations to accept and apply supported --model and --thinking arguments. The PR adds Pi to the extra-argument allowlist. It validates --thinking against PI_THINKING_LEVELS. It normalizes --option=value input and merges the model and thinking arguments into the startup command. Tests cover fresh-session validation, startup planning, valid and invalid thinking levels, and POSIX, PowerShell, and cmd round trips. The existing reuse-session restriction remains covered. Provider and inline-key reconciliation preserves the existing launch safety rules.
Full details: Out of Scope Changes check
Explanation
The changes stay connected to issue #37357. The allowlist, Pi argument parsing, thinking-level validation, default reconciliation, provider conflict handling, API-key protection, startup-command handling, tests, and documentation all support accepting and applying Pi model and thinking overrides. The added shared effort utilities provide the Pi validation list and related level handling. No demonstrated unrelated product behavior or feature change is present.
Full details: Docstring Coverage
Explanation
Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 8 functions across 8 files. (2 skipped: 2 unsupported.)
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Tip
🎯 Customize your risk assessments
Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.
✅ Automatic approvals, with your rules
Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The provider follow-up is now pushed and the PR is linked to #37357. The previous upstream workflow runs show action_required and have no jobs; could a maintainer please check whether the external-PR workflows need approval and run them for the updated commit? Local focused tests passed under Node and Bun; the broader changed-test selection timed out locally, as detailed in the PR description. Thank you!
The reason will be displayed to describe this comment to others. Learn more.
Follow-up Comments
Reject invalid Pi thinking levels.
50-50: Minor · Functional Correctness · Quick win
Reject invalid Pi thinking levels.
If an automation specifies --thinking=bogus, parseExtraAgentArgs accepts it and removeDefaultsFor removes a valid host --thinking value. Pi warns and ignores the invalid level, so each fresh run uses a fallback instead of the saved or host level. Validate Pi thinking levels before accepting the extra argument. Pi’s CLI documents a fixed set of levels and this warning behavior. (raw.githubusercontent.com)
Based on learnings: validate an option’s operand against its contract, not only its presence.
Files skipped from review as they are similar to previous changes: 2
src/cli/specs/automations.ts
docs/site/content/docs/cli/automations.mdx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Follow-up in 7cf8fd8: invalid Pi --thinking values are now rejected before they can replace a host default. The check reuses Orca’s existing Pi thinking-level list; all seven valid levels and both argument forms are covered. Focused tests passed under Node and Bun (586 each). The PR description records the broader local test timeout and remaining CI limitation.
The reason will be displayed to describe this comment to others. Learn more.
Follow-up Comments
Remove the host API key when switching providers.
256-256: Major · Security & Privacy · Quick win
Remove the host API key when switching providers.
If the defaults include --provider anthropic --api-key SECRET, an extra model such as openai/gpt-5 removes the provider but keeps the key. Pi assigns that key to the selected provider, so the request can disclose the Anthropic key to OpenAI and fail authentication. (raw.githubusercontent.com)
Remove the provider-specific key when the provider changes. If the original provider cannot be determined, reject the override rather than forward the key.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@Jinwoo-H, could you review this PR and help approve or route approval of its external-PR workflows for #37357?
The latest commit 1f3a21f fixes compatibility with the thinking-level module moved on upstream main. Against upstream b49a019, the resulting merge tree passed 513 focused tests under Node and 403 under Bun. The complete desktop automation flow was also manually verified on a macOS local build; model and thinking overrides took effect.
The seven workflows for the latest commit still show action_required; the PR Checks run currently has no jobs. The broader local related-test selection timed out, as documented in the PR. Thank you!
Addressed the inline API-key finding in 0449223: a known provider change removes the old inline key, unknown key ownership is rejected, and model overrides are refused when --api-key appears in a custom command. Added regression coverage across POSIX, PowerShell and cmd; the PR description records the scoped test results and the broader timeout.
Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Thanks for all the work here! The same change landed in #38020 (9658ec4), which lets Pi automations accept --model and --thinking extra arguments (with provider reconciliation and docs updates), and #37357 was closed with it. Closing as superseded. If something from this PR is still missing on main, a focused follow-up would be welcome.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
A scheduled Pi task can choose its own model and thinking level without changing the defaults for every Pi session.
What Changed
--modeland--thinkingas extra arguments for fresh automation sessions, including--option=valueinput, and validate thinking levels against the existing Pi level list.--provider, while a bare model or a matching provider keeps it.--boundaries when merging arguments, and document how to qualify gateway model IDs containing/.Why
Pi previously failed the existing extra-argument allowlist even though these options are safe model-selection settings. Reusing the existing validation and launch path preserves the fresh-session and safety restrictions. Reconciling the provider is necessary because Pi restricts model lookup when
--provideris present.Linked Issue
Fixes #37357
Visual Proof
No before/after screenshot captured. The existing Extra arguments field becomes enabled for Pi; validation and launch behavior are covered by automated tests.
Testing
7cf8fd8on upstream94f2be1, creating or editing and running an automation in the desktop UI and confirming both Pi model and thinking options took effect.0449223was simulated against upstreamb49a019: the resulting tree passed 531 focused tests under Node and 421 startup tests under Bun, including inline API-key security cases.pnpm check:changed --base=b49a019e87f85746d941e5c05c5056a2d4a5289c --maxWorkers=1 --timeout=2passed 20 of 21 checks, including typechecks, lint and formatting; the broad related-unit-test selection hit the two-minute timeout. It is not a full passing run.Risk
Level: Medium. Provider-qualified Pi models can select a different provider, so gateway IDs must include the gateway prefix. A provider change drops a default inline API key; unknown key ownership or a key in a custom command causes the override to be refused. Configure credentials in Pi per provider. Existing saved extras and older paired/remote hosts keep the existing compatibility checks; no data migration is performed. A plain revert restores the previous behavior, but saved Pi extras would then be rejected until removed or the fix restored.
AI Disclosure
Developed and updated with assistance from the Pi coding agent using
openai-codex/gpt-6.1-terra; the PR also received an automated CodeRabbit review.Review
Reviewed the actual Pi model resolver, the shared merge callers, shell round trips, and provider-conflict behavior.
Agent skill upstream boundary
Notes
Input allowlisting, shell quoting, fresh-session validation, and remote compatibility remain in the existing shared paths. No platform-specific execution behavior or mobile protocol was added.
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (the focused changed gate is recorded above; upstream CI still needs to run)