Add Anthropic API inference for Planner and research - #1
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Chopin currently uses the channel owner's Copilot entitlement for every hosted model session. This adds
AGENT_PROVIDER=anthropicso a deployment can pay for Planner and background-worker inference with its ownANTHROPIC_API_KEY, while retaining GitHub sign-in and repository authorization. Copilot remains the default.Behavior
pause_turncontinuations, and limit requests, searches, response bytes, and output tokens. Provider failures, missing citations, and incomplete responses fail the job.Configuration
The Anthropic API model ID uses
5-1, rather than Copilot's5.1. No database migration is required. The key must be provisioned through the deployment's secret manager and injected into the app; external AWS/CDK deployment changes are not part of this fork PR.Validation
bun test: 1,446 passed, 6 skipped (the existing opt-in PostgreSQL tests and four opt-in provider contract tests).bun run test:anthropic: 4 passed using the pinned CLI and local mock Anthropic endpoints, covering wire model/key routing, streaming, allowed/denied tools, terminal results, and provider authentication failure.bun run ci,bun run types, andbun run build: passed.Limits and deployment verification
No live Anthropic key was used. The mock tests establish runtime/protocol behavior, not access to Fable 5.1 or live research quality for a deployment's account. Verify a Planner edit and a research request with the deployment key before rollout.
Copilot credit ceilings do not measure BYOK usage and are omitted in Anthropic sessions. Existing job deadlines and input/artifact bounds remain; direct public search has explicit request/search/output limits. The pinned runtime ignored its advertised
provider.maxOutputTokensoverride in a local wire-level probe, so this PR does not expose that ineffective setting or claim a per-session dollar/token budget. Planner/private-worker token limits remain runtime-selected; deployments should configure provider-side spending limits.Note
Medium Risk
Introduces a deployment-wide API key and splits model credentials from GitHub authorization on core Planner, worker, and research paths; behavior is opt-in with startup validation and broad mocked contract tests, but live rollout still needs key and spend controls verified.
Overview
Adds
AGENT_PROVIDER=anthropicso self-hosted deployments can bill Planner, background workers, and related jobs through a server-sideANTHROPIC_API_KEYinstead of each channel owner’s Copilot entitlement. Copilot stays the default; startup rejects unknown providers or missing keys rather than falling back.Planner and private workers use the Copilot SDK’s Anthropic BYOK provider (no
gitHubTokenas the model credential). GitHub App tokens still drive repository tools and read-only GitHub MCP. Sessions verify the configured model after agent selection, log usage without prompts or keys, and omit CopilotmaxAiCreditsin Anthropic mode.Public research in Anthropic mode bypasses the Copilot public-web worker and calls Anthropic’s Messages API with only the public brief and
web_search_20250305, with bounded continuations, citation/provenance checks, and existing artifact validation.CI gains
bun run test:anthropic(mock contract tests). Compose,.env.example, and hosting docs document the new variables and ownership wording (“Planner owner” vs Copilot-only).Reviewed by Cursor Bugbot for commit 99b0ce6. Bugbot is set up for automated code reviews on this repo. Configure here.