Skip to content

feat: add Pi.dev Agent SDK support as a first-class AI assistant provider#1

Merged
dammyammy merged 2 commits intodevfrom
copilot/add-pi-dev-agent-sdk-support
Apr 11, 2026
Merged

feat: add Pi.dev Agent SDK support as a first-class AI assistant provider#1
dammyammy merged 2 commits intodevfrom
copilot/add-pi-dev-agent-sdk-support

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 11, 2026

Summary

Adds Pi.dev as a third AI assistant provider alongside Claude and Codex. Pi is a multi-provider coding agent SDK that supports Anthropic, OpenAI, Google, Mistral, OpenRouter, and many other LLM providers through a single unified interface.

Changes

New client: packages/core/src/clients/pi.ts

  • PiClient implementing IAssistantClient using @mariozechner/pi-coding-agent SDK
  • Bridges Pi's event subscription model to Archon's AsyncGenerator<MessageChunk> interface via a queue-based adapter
  • Supports streaming text deltas, thinking tokens, tool calls, and tool results
  • Model selection via provider/model-id format (e.g. anthropic/claude-opus-4-5, openai/gpt-4o)
  • Abort signal support via session.abort()
  • Session resume not supported (Pi uses in-memory sessions; logs a warning and starts fresh)

Provider type propagation

All 'claude' | 'codex' type unions updated to 'claude' | 'codex' | 'pi' across:

  • packages/core/src/config/config-types.tsPiAssistantDefaults, MergedConfig, SafeConfig, GlobalConfig, RepoConfig
  • packages/core/src/config/config-loader.ts — defaults, merge, env override, toSafeConfig, updateGlobalConfig
  • packages/workflows/src/deps.tsAssistantClientFactory, WorkflowConfig
  • packages/workflows/src/schemas/dag-node.ts — provider enum
  • packages/workflows/src/schemas/workflow.ts — provider enum
  • packages/workflows/src/model-validation.tsisModelCompatible accepts 'pi' (all models valid)
  • packages/workflows/src/executor.tsresolvedProvider type
  • packages/workflows/src/loader.ts — provider acceptance check
  • packages/workflows/src/dag-executor.ts — all provider type annotations, pi option building branch
  • packages/workflows/src/validator.ts — pi warnings for Claude-only features (hooks, MCP, skills, tool restrictions)
  • packages/server/src/routes/schemas/config.schemas.ts — API schema enums
  • packages/server/src/routes/api.ts — config update handler
  • packages/cli/src/commands/setup.tsdefaultAssistant type annotation
  • packages/core/src/clients/factory.ts and index.ts — factory and export

Documentation

  • README.md — new "Using Pi.dev as Your AI Backend" section with setup instructions, supported providers table, and workflow YAML examples

Notes for reviewers

  • bun.lock not updated: bun install must be run to pull @mariozechner/pi-coding-agent@^0.66.1 and update the lockfile. This is expected — the sandboxed environment does not have bun available.
  • api.generated.d.ts not updated: This file is auto-generated from the OpenAPI spec. Run bun run dev:server then bun --filter @archon/web generate:types to regenerate after this PR is merged.
  • Pi-specific limitations: Claude-only features (hooks, MCP servers per-node, skills, structured output, env injection) are silently ignored for provider: pi. Validator warnings were added for hooks, MCP, skills, and tool restrictions.
  • CodeQL: 0 security alerts found.

Copilot AI and others added 2 commits April 11, 2026 16:24
@dammyammy dammyammy marked this pull request as ready for review April 11, 2026 21:20
Copilot AI review requested due to automatic review settings April 11, 2026 21:20
@dammyammy dammyammy merged commit f258a4a into dev Apr 11, 2026
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

Adds Pi.dev as a third AI assistant provider in Archon, integrating the @mariozechner/pi-coding-agent SDK into the existing assistant client + workflow execution architecture.

Changes:

  • Introduces a new PiClient implementing IAssistantClient, bridging Pi’s event stream to Archon’s AsyncGenerator<MessageChunk> streaming interface.
  • Propagates provider: 'pi' support across config types/loaders, workflow schemas/parsing, execution, validation, and server API schemas/handlers.
  • Updates README documentation to describe Pi setup and usage.

Reviewed changes

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

Show a summary per file
File Description
README.md Documents Pi as an AI backend (setup, env vars, model format, workflow examples).
packages/workflows/src/validator.ts Adds Pi-specific warnings for Claude-only features (MCP, skills, hooks, tool restrictions).
packages/workflows/src/schemas/workflow.ts Extends workflow-level provider enum to include pi.
packages/workflows/src/schemas/dag-node.ts Extends node-level provider enum to include pi.
packages/workflows/src/model-validation.ts Allows all models when provider is pi.
packages/workflows/src/loader.ts Accepts pi as a valid provider during workflow parsing.
packages/workflows/src/executor.ts Expands resolved provider typing to include pi (with comment about inference).
packages/workflows/src/deps.ts Extends workflow config + assistant factory types to include pi and Pi assistant defaults.
packages/workflows/src/dag-executor.ts Adds Pi option-building branch for node execution (model-only support).
packages/server/src/routes/schemas/config.schemas.ts Extends API config schemas to include pi assistant config.
packages/server/src/routes/api.ts Allows updating Pi assistant config via the config PATCH route.
packages/core/src/services/title-generator.ts Updates docs to include pi as a possible assistant type.
packages/core/src/config/config-types.ts Adds PiAssistantDefaults and extends assistant/provider unions to include pi.
packages/core/src/config/config-loader.ts Adds Pi defaults, merge behavior, env overrides, and safe config mapping.
packages/core/src/clients/pi.ts New Pi client implementation using Pi agent SDK + queue-based stream adapter.
packages/core/src/clients/index.ts Re-exports PiClient.
packages/core/src/clients/factory.ts Adds factory support for type === 'pi'.
packages/core/package.json Adds @mariozechner/pi-coding-agent dependency.
packages/cli/src/commands/setup.ts Expands default assistant typing to include pi.

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

Comment thread README.md

- id: implement
depends_on: [plan]
provider: anthropic # per-node override (uses node-level provider)
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The workflow example uses provider: anthropic, but workflow/node provider only accepts the assistant providers (claude, codex, pi). For Pi, keep provider: pi and set the Anthropic model via model: anthropic/<model-id>; if you intend to use the native Claude client, use provider: claude instead.

Suggested change
provider: anthropic # per-node override (uses node-level provider)
provider: pi # per-node override (uses Pi with the node-level model)

Copilot uses AI. Check for mistakes.
Comment on lines +338 to 342
// Warn if using MCP with Codex or Pi
if (provider === 'codex' || provider === 'pi') {
issues.push({
level: 'warning',
nodeId: node.id,
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

Validator behavior changed to warn for provider === 'pi', but the existing validator test suite only covers the Codex warnings. Add equivalent test cases asserting warnings for Pi (MCP, skills, hooks, tool restrictions) so this new provider path stays covered.

Copilot uses AI. Check for mistakes.
Comment on lines 279 to 283
// When workflow sets a model but not a provider, infer provider from the model.
// e.g. model: sonnet → provider: claude, even if config.assistant is codex.
let resolvedProvider: 'claude' | 'codex';
// Pi workflows should always set provider: pi explicitly (pi models cannot be auto-inferred).
let resolvedProvider: 'claude' | 'codex' | 'pi';
let providerSource: string;
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The comment here notes that Pi “cannot be auto-inferred”, but the provider-resolution logic later in this function still infers a non-Claude workflow.model to codex when workflow.provider is omitted. That means a defaultAssistant: pi setup can silently switch to Codex just by setting model at the workflow level. Consider adding explicit handling for config.assistant === 'pi' (or provider/model-id model strings) so Pi remains the resolved provider unless the workflow explicitly opts out.

Copilot uses AI. Check for mistakes.

// Determine default assistant
let defaultAssistant: 'claude' | 'codex' = 'claude';
let defaultAssistant: 'claude' | 'codex' | 'pi' = 'claude';
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

defaultAssistant is now typed to include 'pi', but this setup flow only reasons about Claude/Codex (hasClaude/hasCodex) and never offers/configures Pi. Either add Pi detection + selection + config generation, or keep the type here limited to assistants that archon setup can actually configure so the generated config doesn’t imply unsupported values.

Suggested change
let defaultAssistant: 'claude' | 'codex' | 'pi' = 'claude';
let defaultAssistant: 'claude' | 'codex' = 'claude';

Copilot uses AI. Check for mistakes.
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