Skip to content

feat(pi): add thinking option for reasoning level control#584

Open
jerome-benoit wants to merge 2 commits into
mattpocock:mainfrom
jerome-benoit:feat/pi-thinking-option
Open

feat(pi): add thinking option for reasoning level control#584
jerome-benoit wants to merge 2 commits into
mattpocock:mainfrom
jerome-benoit:feat/pi-thinking-option

Conversation

@jerome-benoit
Copy link
Copy Markdown
Contributor

Summary

Expose pi's --thinking CLI flag through PiOptions, matching the effort option on claudeCode/codex and variant on opencode.

Changes

  • src/AgentProvider.ts: Added thinking?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" to PiOptions and wired --thinking flag in buildPrintCommand.
  • src/AgentProvider.test.ts: Added 4 tests covering presence, absence, empty options, and all 6 thinking levels.

Usage

import { pi } from "@ai-hero/sandcastle";

// Without thinking (unchanged behavior)
pi("claude-sonnet-4-6");

// With thinking (new)
pi("claude-sonnet-4-6", { thinking: "high" });
// → pi -p --mode json --no-session --thinking high --model 'claude-sonnet-4-6'

Design decisions

  • Typed union (not string): Pi has a fixed, documented set of 6 levels (off, minimal, low, medium, high, xhigh). Using a union provides compile-time safety — same pattern as claudeCode and codex.
  • No shell-escaping needed: Values come from a typed union of known-safe alphanumeric strings — same approach as claudeCode's effort.
  • buildInteractiveArgs unchanged: Pi's TUI manages thinking level via Shift+Tab — no need to pass it on the interactive command line.

Closes #583

Expose pi's `--thinking` CLI flag through `PiOptions`, matching the
`effort` option on `claudeCode`/`codex` and `variant` on `opencode`.

Uses a typed union (`"off" | "minimal" | "low" | "medium" | "high" | "xhigh"`)
since pi has a fixed, known set of valid thinking levels.

Closes mattpocock#583
Copilot AI review requested due to automatic review settings May 6, 2026 21:45
@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 2026

@jerome-benoit is attempting to deploy a commit to the Matt Pocock's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR exposes pi’s --thinking reasoning level flag via a new PiOptions.thinking option, aligning pi with the existing “reasoning control” options supported by other agent providers.

Changes:

  • Added thinking?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" to PiOptions.
  • Updated pi().buildPrintCommand() to append --thinking <level> when configured.
  • Added unit tests to verify --thinking is included/omitted correctly and supports all levels.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/AgentProvider.ts Adds the thinking option to PiOptions and wires it into the generated pi print command.
src/AgentProvider.test.ts Adds coverage for the new thinking flag behavior and supported levels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/AgentProvider.ts
Comment thread src/AgentProvider.ts
README update deferred — same rationale as mattpocock#582: PiOptions section
will be added when the provider options docs are restructured.
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.

Add thinking option to the pi agent provider

2 participants