Separate runtime providers from modes - #105
Conversation
Claude-Session-Id: 01a04225-f4a8-7490-b9e7-6db50c066bbb
…n to sessions Split composite `backend` column that conflated provider, mode, and adapter ID into explicit columns. Add `parent_relation` to distinguish agent vs transcript parent relationships. Views expose new columns via aliasing for compatibility. Backfill handles divergent vocabularies from multiple sources idempotently. Add migration safety test for co-tenant enum preservation.
Migrate from backend-prefixed model names (claude-agent-opus) to explicit `mode:` field combined with normalized model names (claude-opus-5). Centralizes runtime resolution via ai.Resolve() to consider both model family and authored mode together. Authored mode is now validated — cannot be silently dropped. Updates all test fixtures and adds contract validation that mode selection pins the runtime choice.
Rename Backend to Mode and introduce Provider field in the Runtime abstraction, separating execution mode (API, CLI, Agent) from LLM provider (Anthropic, OpenAI, etc.). GetBackend() method replaced with GetRuntime() returning a Runtime struct. BREAKING CHANGE: GetBackend() removed; Backend field replaced with Mode and Provider fields in Model struct.
…irs resolved upfront Split the ambiguous Backend enum—which meant adapter outbound, mode inbound—into Provider (family) and RuntimeMode (mechanism), resolved once at the boundary before any factory runs. Key changes: - Model.Backend deleted; Model now carries Provider + Mode fields set by Resolve - All provider factories receive pre-resolved models; no re-normalization - RuntimeOf(provider, mode) creates the pair; ProviderFor(name) derives only family - GetBackend() → GetRuntime() throughout; update all adapter interfaces - Wire format: `backend` key becomes `mode`; provider lives off-wire - Sandbox: SandboxNone→SandboxOff, SandboxSRT→SandboxSRTInternal, introduce SandboxNative - Remove composite mode tokens from claim table; mode comes from selector or default Impact: Model captain records and model the CLI receives are now identical. Sandbox policy translates uniformly across all providers via api.TranslateClaudeSandbox and api.TranslateCodexSandbox.
…mposite adapters
Replace the flat Backend identifier ("claude-agent", "codex-cli") with an explicit (provider, mode) pair. Provider names the family (anthropic, openai, google, deepseek); mode names the mechanism (api, agent, cli, cmux).
Separate permission mode from sandbox isolation. Whether an agent asks before acting is now independent of what it can reach, fixing the confusing equivalence where `sandbox: off` forced `bypassPermissions`.
Sandbox refactoring: rename SandboxNone→Off, SandboxSRT→Native, SandboxContainer→Docker. SandboxRef.Backend becomes SandboxRef.Mode. Add provider-neutral NativeSandboxPolicy with per-provider translators.
Config changes: remove global ai.backend/model/reasoningEffort; move under ai.providers.<provider>. Add agent_resources.go to declare what each CLI sees, runtime_arguments.go to map native flags to Spec paths.
BREAKING CHANGE: Backend type removed; use Runtime{Provider, Mode}. Config format changed; old files rejected with migration guidance.
Replace the monolithic Backend enum with a two-axis Runtime system: Provider (the model family: Anthropic, OpenAI, Google, DeepSeek) and Mode (the execution mechanism: api, agent, cli, cmux). This decouples family selection from runtime selection so each can be configured independently. - ModelProvider replaces Backend as the family descriptor - RuntimeMode replaces the mode suffix in backend names - All adapter, model, and schema operations now take (Provider, Mode) instead of Backend - Model definitions now carry Provider+Mode fields instead of Backend - Runtime selection logic restructured to select along independent axes - Updates signature of ResolveAPIKey, ListModels, RegistryModelDefs, and other model discovery functions to reflect the two-axis design - Keeps all external APIs and behavior unchanged; internal refactoring only
BREAKING CHANGE: Wire format for runtime selection changes from {"backend":"adapter-name"} to {"mode":"api|agent|cli"}; provider is inferred from model name. Thread.Runtime type changes from *api.Model to *api.RuntimeIdentity.
The monolithic Backend enum conflated provider identity (Anthropic, OpenAI) with execution mode (API, Agent, CLI), making invalid runtime states constructible and confusing credentials (per-provider) with runtime choices (per-turn). This split separates concerns: Provider is a ModelProvider struct identifying API endpoints and agent binaries; Mode is the runtime mechanism chosen at execution time. Credentials belong to a provider; mode is a per-turn choice that does not affect authentication.
Thread locking now uses RuntimeIdentity (model/provider/mode) to avoid earlier bugs where hand-built identities omitted Mode, allowing clients to post a different runtime than the one they read. Also adds history recovery for incomplete terminal sessions, terminal execution atomicity, and improved HTTP error status codes for concurrency conflicts.
…te management Refactor the prompt workbench into modular components and improve state management to support concurrent editing of multiple prompts: - Extract `PromptDetailPane`, `PromptSidebar`, `PromptWorkbenchActions`, `PromptCatalogView`, `PromptDeleteDialog` into separate components for maintainability - Move state management to per-prompt slots, enabling drafts to survive navigation between prompts - Implement conflict detection via `baseVersion` on save - Add duplicate and delete confirmation UX - Support repair mode for prompts with parse errors - Refetch permission catalog when runtime selection changes (keyed by resolved adapter) - Show file destination preview before creating/saving a prompt - Extract API utilities to `promptWorkbenchApi`, `promptDetailState`, `promptWriteDestination`, `promptAgentTools` - Update documentation terminology: `backend` → `mode` (runtime mechanism: api/agent/cli/cmux)
…gent sessions Replaces bufio.Scanner with a custom jsonl.Reader that has no hardcoded line size limit, avoiding silent truncation of large JSONL entries (e.g., Codex compaction records). Refactors Codex session building to properly handle forked/subagent threads as separate sessions linked to their parent, preventing duplicate turn records on (session_id, provider_turn_id). Clarifies Provider, ModelMode, and ExecutionMode fields in the session model.
…d mode
Replace the composite Backend enum (e.g., BackendClaudeAgent, BackendCodexCLI) with independent Provider (*api.ModelProvider) and Mode (api.RuntimeMode) fields throughout the CLI. This allows independent reasoning about provider families and execution mechanisms, enabling clearer expression of which providers support which modes and stricter validation.
BREAKING CHANGE: Configuration field "backend" becomes "mode" and "provider"; JSON output changes from {"backend":"..."} to {"provider":"...","mode":"..."}. Migration required for saved configurations and external tools depending on the old contract.
The "backend" concept was overloaded: it named both the adapter identity (anthropic, openai) and the composite runtime mechanism (api, cli, agent, cmux). This conflation made it impossible to derive one axis from the other. Split into two explicit concepts: - **provider**: the LLM family (derived from model name or explicitly chosen) - **mode**: the execution mechanism (api|cli|agent|cmux), explicit from model prefix or CLI flag Updates database schema via migrations 79–80, which recover both axes from composite values recorded in metadata and transcripts. Adds session hierarchy tracking (agent vs transcript children) to exclude provider mirrors from thread views. Improves prompt run error reporting and conflict detection. All APIs, CLI flags, and test fixtures updated. Backward compatibility for task.json payloads validated at runtime. Sandbox kind names aligned with actual behavior (docker, off, native, srt).
|
Important Review skippedToo many files! This PR contains 445 files, which is 345 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 300 files. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (445)
You can disable this status message by setting the 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. Comment |
Gavel summary
Totals: 0 passed · 0 failed · 0 skipped · - |
Gavel summary
Totals: 3638 passed · 12 failed · 11 skipped · 3m49s Failing testsginkgo Timeout[1/2] run "direct" iteration 1/1 (model=direct-model)… ginkgo Timeout'/home/runner/work/captain/captain/.ginkgo/ginkgo-report-.-pkg-gitagent-1788275221751572862.json' not found '/home/runner/work/captain/captain/.ginkgo/ginkgo-report-.-pkg-database-1788275215736568042.json' not found |
Replace monolithic Backend enum with separate ModelProvider and RuntimeMode types to clarify the distinction between "which provider" and "how it's invoked". This improves type safety and enables flexible runtime combinations. Update all provider registration, configuration, and observation code to use the new Provider+Mode pair. Remove Backend field from runtime observations. BREAKING CHANGE: Backend-keyed API surface replaced with Provider+Mode pair; callers must update RegisterProvider(), ResolveRuntimeSelectors(), and related function signatures.
| type RuntimeIdentity struct { | ||
| Model string `json:"model,omitempty"` | ||
| Mode RuntimeMode `json:"mode,omitempty"` | ||
| Provider string `json:"provider,omitempty"` | ||
| Effort Effort `json:"effort,omitempty"` | ||
| } |
There was a problem hiding this comment.
| type RuntimeIdentity struct { | |
| Model string `json:"model,omitempty"` | |
| Mode RuntimeMode `json:"mode,omitempty"` | |
| Provider string `json:"provider,omitempty"` | |
| Effort Effort `json:"effort,omitempty"` | |
| } | |
| type RuntimeIdentity struct { | |
| Runtime | |
| Model string `json:"model,omitempty"` | |
| Effort Effort `json:"effort,omitempty"` | |
| }``` |
Claude-Session-Id: 01a05ce8-8352-7740-ac44-d48f1b792cb4
Claude-Session-Id: 01a05ce8-8352-7740-ac44-d48f1b792cb4
Claude-Session-Id: 01a05ce8-8352-7740-ac44-d48f1b792cb4
Claude-Session-Id: 01a05ce8-8352-7740-ac44-d48f1b792cb4
Claude-Session-Id: 01a05ce8-8352-7740-ac44-d48f1b792cb4
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
What
Notes
backendwithproviderandmode; migrations are required for saved configurations and external tools.