Skip to content

Support Pi extra arguments in automations - #37320

Closed
reason211 wants to merge 5 commits into
stablyai:mainfrom
reason211:fix/automation-pi-extra-args
Closed

reason211 wants to merge 5 commits into
stablyai:mainfrom
reason211:fix/automation-pi-extra-args

Conversation

@reason211

@reason211 reason211 commented Nov 2, 2026 •

Copy link
Copy Markdown

ELI5

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.

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

  • 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)

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

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.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

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: Passed 5
Check name Status Explanation
Title check Passed 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 Passed 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 Passed 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 Passed 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 Passed 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.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c541504-5977-4cba-ba9f-6d87c7a03ac0
Commits

Reviewing files that changed from the base of the PR and between 1f3a21f and 0449223.

Files selected for processing: 9
  • docs/site/content/docs/cli/automations.mdx
  • skill-guides/orca-cli/references/automations.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/specs/automations.ts
  • src/shared/agent-session/options/agent-session-option-agent-args.ts
  • src/shared/agent-startup-plan-inputs-extra-agent-args.spec.ts
  • src/shared/automation-extra-agent-args.spec.ts
  • src/shared/automation-extra-agent-args.ts
  • src/shared/tui-agent-launch-command.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a813869-b956-4eb6-b41f-66f0d4c972f9
Commits

Reviewing files that changed from the base of the PR and between 98d22fa and 25f2cdc.

Files selected for processing: 8
  • docs/site/content/docs/cli/automations.mdx
  • skill-guides/orca-cli/references/automations.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/specs/automations.ts
  • src/shared/agent-session/options/agent-session-option-agent-args.ts
  • src/shared/agent-startup-plan-inputs-extra-agent-args.spec.ts
  • src/shared/automation-extra-agent-args.spec.ts
  • src/shared/automation-extra-agent-args.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Keep the host provider for bare or matching model references, and remove conflicting providers for qualified overrides.
@reason211

Copy link
Copy Markdown
Author

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!

@coderabbitai coderabbitai 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.

Follow-up Comments

Outside diff 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.

Source: Learnings

Open the source location


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 320e1069-4f32-46e3-9eab-db1a7e08e625
Commits

Reviewing files that changed from the base of the PR and between 25f2cdc and 2deb129.

Files selected for processing: 8
  • docs/site/content/docs/cli/automations.mdx
  • skill-guides/orca-cli/references/automations.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/specs/automations.ts
  • src/shared/agent-session/options/agent-session-option-agent-args.ts
  • src/shared/agent-startup-plan-inputs-extra-agent-args.spec.ts
  • src/shared/automation-extra-agent-args.spec.ts
  • src/shared/automation-extra-agent-args.ts
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.

Reject unsupported thinking levels before they can replace a valid host default.
@reason211

Copy link
Copy Markdown
Author

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.

Use the upstream module location so the PR also builds after merging.

@coderabbitai coderabbitai 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.

Follow-up Comments

Outside diff 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.

Open the source location

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 08cd1464-2cdd-4c53-af27-0b547d419918
Commits

Reviewing files that changed from the base of the PR and between 7cf8fd8 and 1f3a21f.

Files selected for processing: 2
  • src/shared/agent-session/options/structured-agent-session-effective-effort.ts
  • src/shared/automation-extra-agent-args.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@reason211

Copy link
Copy Markdown
Author

@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!

Drop a known provider key when switching providers and reject ambiguous inline credentials.
@reason211

Copy link
Copy Markdown
Author

@coderabbitai review

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.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

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.

@nwparker

nwparker commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

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.

@nwparker nwparker closed this Nov 5, 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.

[Bug]: Pi automations reject extra model and thinking arguments

3 participants