Skip to content

An open-source, faster Devin alternative

TypeScript

feat(web): choose runtime (claude/codex) in the agent UI

Igor Zalutski80d2c6122c24
diff --git a/web/src/lib/runtimes.ts b/web/src/lib/runtimes.ts
new file mode 100644
index 00000000..6fbf834c
--- /dev/null
+++ b/web/src/lib/runtimes.ts
@@ -0,0 +1,56 @@
+// The runtimes the dashboard exposes, with their models + credential provider.
+// The v3 API pairs each runtime with a provider (claude→anthropic, codex→openai)
+// and requires a provider-prefixed model id, so everything model/credential-related
+// keys off this one table — keeping the create dialog and the agent detail screen in
+// sync. More runtimes (and models) land here as they ship.
+
+export type RuntimeModel = { value: string; label: string }
+
+export type RuntimeOption = {
+ value: string // the API `runtime` value
+ label: string
+ provider: string // credential provider + model-id prefix
+ keyLabel: string // label for the inline "new credential" key field
+ keyPlaceholder: string
+ models: RuntimeModel[]
+}
+
+export const RUNTIMES: RuntimeOption[] = [
+ {
+ value: 'claude',
+ label: 'Claude',
+ provider: 'anthropic',
+ keyLabel: 'Anthropic API key',
+ keyPlaceholder: 'sk-ant-…',
+ models: [
+ { value: 'anthropic/claude-opus-4-8', label: 'Claude Opus 4.8' },
+ { value: 'anthropic/claude-sonnet-4-6', label: 'Claude Sonnet 4.6' },
+ { value: 'anthropic/claude-haiku-4-5', label: 'Claude Haiku 4.5' },
+ ],
+ },
+ {
+ value: 'codex',
+ label: 'Codex',
+ provider: 'openai',
+ keyLabel: 'OpenAI API key',
+ keyPlaceholder: 'sk-…',
+ models: [{ value: 'openai/gpt-5-codex', label: 'GPT-5 Codex' }],
+ },
+]
+
+export const DEFAULT_RUNTIME = RUNTIMES[0].value
+
+export const runtimeOptions = RUNTIMES.map((r) => ({
+ value: r.value,
+ label: r.label,
+}))
+
+// Falls back to the first runtime for an unknown/loading value, so callers can pass
+// `agent?.runtime` safely.
+export function getRuntime(value: string | undefined): RuntimeOption {
+ return RUNTIMES.find((r) => r.value === value) ?? RUNTIMES[0]
+}
+
+export function defaultModelFor(runtime: string): string {
+ return getRuntime(runtime).models[0].value
+}
diff --git a/web/src/pages/AgentDetail.tsx b/web/src/pages/AgentDetail.tsx
index 62196c59..49ceb405 100644
--- a/web/src/pages/AgentDetail.tsx
+++ b/web/src/pages/AgentDetail.tsx
@@ -27,18 +27,10 @@ import { EmptyState } from '@/components/empty-state'
import { ResourceTable, type Column } from '@/components/resource-table'
import { Skeleton } from '@/components/ui/skeleton'
import { SlackConnect } from '@/components/slack-connect'
+import { getRuntime } from '@/lib/runtimes'
-// Mirrors the curated list in Agents.tsx (the create flow). The API wants a
-// provider-prefixed model id.
-const MODELS = [
- { value: 'anthropic/claude-opus-4-8', label: 'Claude Opus 4.8' },
- { value: 'anthropic/claude-sonnet-4-6', label: 'Claude Sonnet 4.6' },
- { value: 'anthropic/claude-haiku-4-5', label: 'Claude Haiku 4.5' },
-]
-
-// Agents run on the "claude" runtime → anthropic credentials. Sentinels for the
-// non-credential choices in the picker.
-const CRED_PROVIDER = 'anthropic'
+// Sentinels for the non-credential choices in the picker. The model list +
+// credential provider come from the agent's runtime (see @/lib/runtimes).
const ORG_DEFAULT = '__default__' // no pinned credential → org default resolves
const NEW_CRED = '__new__' // create one inline
@@ -69,11 +61,14 @@ export default function AgentDetail() {
queryKey: ['credentials'],
queryFn: getCredentials,
})
- const anthropicCreds = (credentials ?? []).filter(
- (c) => c.provider === CRED_PROVIDER,
+ // Model list + credential provider follow the agent's runtime (immutable after
+ // create): claude→anthropic, codex→openai. Falls back to claude while loading.
+ const rt = getRuntime(agent?.runtime)
+ const providerCreds = (credentials ?? []).filter(
+ (c) => c.provider === rt.provider,
)
const credLabel = (id: string) => {
- const c = anthropicCreds.find((x) => x.id === id)
+ const c = providerCreds.find((x) => x.id === id)
if (!c) return id
return `${c.name || 'Unnamed'}${c.last4 ? ` ·· ${c.last4}` : ''}${
c.is_default ? ' (default)' : ''
@@ -152,9 +147,9 @@ export default function AgentDetail() {
mutationFn: async () => {
const cred = await createCredential({
key: newCredKey.trim(),
- provider: CRED_PROVIDER,
+ provider: rt.provider,
name: newCredName.trim() || undefined,
- is_default: !anthropicCreds.some((c) => c.is_default),
+ is_default: !providerCreds.some((c) => c.is_default),
})
return updateAgent(agentId, { credential: cred.id })
},
@@ -172,9 +167,9 @@ export default function AgentDetail() {
const credSaving = switchCredMutation.isPending || addCredMutation.isPending
// Derived control values.
- const modelOptions = MODELS.some((m) => m.value === agent?.model)
- ? MODELS
- : [{ value: agent?.model ?? '', label: agent?.model ?? '' }, ...MODELS]
+ const modelOptions = rt.models.some((m) => m.value === agent?.model)
+ ? rt.models
+ : [{ value: agent?.model ?? '', label: agent?.model ?? '' }, ...rt.models]
const savedPrompt = agent?.prompt ?? ''
const promptValue = promptDraft ?? savedPrompt
const promptDirty = promptDraft !== undefined && promptDraft !== savedPrompt
@@ -183,7 +178,7 @@ export default function AgentDetail() {
: (agent?.credential_id ?? ORG_DEFAULT)
const credOptions = [
{ value: ORG_DEFAULT, label: 'Org default (no pinned credential)' },
- ...anthropicCreds.map((c) => ({ value: c.id, label: credLabel(c.id) })),
+ ...providerCreds.map((c) => ({ value: c.id, label: credLabel(c.id) })),
{ value: NEW_CRED, label: '+ New credential…' },
]
const onCredChange = (v: string) => {
@@ -359,7 +354,7 @@ export default function AgentDetail() {
/>
</Field>
<Field
- label="Anthropic API key"
+ label={rt.keyLabel}
htmlFor="new-cred-key"
description="Encrypted in a dedicated secret store."
>
@@ -368,7 +363,7 @@ export default function AgentDetail() {
type="password"
value={newCredKey}
onChange={(e) => setNewCredKey(e.target.value)}
- placeholder="sk-ant-…"
+ placeholder={rt.keyPlaceholder}
/>
</Field>
<div className="flex justify-end gap-2 sm:col-span-2">
diff --git a/web/src/pages/Agents.tsx b/web/src/pages/Agents.tsx
index 9f4dbe07..3b40c250 100644
--- a/web/src/pages/Agents.tsx
+++ b/web/src/pages/Agents.tsx
@@ -24,19 +24,15 @@ import {
import { Field, Input, Select, Textarea } from '@/components/form'
import { EmptyState } from '@/components/empty-state'
import { ResourceTable, type Column } from '@/components/resource-table'
+import {
+ DEFAULT_RUNTIME,
+ defaultModelFor,
+ getRuntime,
+ runtimeOptions,
+} from '@/lib/runtimes'
-// Curated model list. The API requires a provider-prefixed id; runtime "claude" ⇒
-// anthropic/… (codex/openai land when that runtime ships).
-const MODELS = [
- { value: 'anthropic/claude-opus-4-8', label: 'Claude Opus 4.8' },
- { value: 'anthropic/claude-sonnet-4-6', label: 'Claude Sonnet 4.6' },
- { value: 'anthropic/claude-haiku-4-5', label: 'Claude Haiku 4.5' },
-]
-const DEFAULT_MODEL = MODELS[0].value
-
-// Agents run on the "claude" runtime → anthropic credentials. Sentinel for the
-// "create one inline" choice in the credential picker.
-const CRED_PROVIDER = 'anthropic'
+// Sentinel for the "create one inline" choice in the credential picker. The model
+// list + credential provider both follow the chosen runtime (see @/lib/runtimes).
const NEW_CRED = '__new__'
export default function Agents() {
@@ -51,45 +47,63 @@ export default function Agents() {
queryKey: ['credentials'],
queryFn: getCredentials,
})
- const anthropicCreds = (credentials ?? []).filter(
- (c) => c.provider === CRED_PROVIDER,
- )
- const hasDefault = anthropicCreds.some((c) => c.is_default)
-
const [showCreate, setShowCreate] = useState(false)
const [name, setName] = useState('')
const [prompt, setPrompt] = useState('')
- const [model, setModel] = useState(DEFAULT_MODEL)
+ const [runtime, setRuntime] = useState(DEFAULT_RUNTIME)
+ const [model, setModel] = useState(defaultModelFor(DEFAULT_RUNTIME))
// Credential selection: a credential id or NEW_CRED (create inline). '' is
// resolved to a sensible default on dialog open.
const [credChoice, setCredChoice] = useState('')
const [newCredName, setNewCredName] = useState('')
const [newCredKey, setNewCredKey] = useState('')
- // Pick the lowest-friction default each time the dialog opens: the org default
- // credential if any, else the first existing one, else "new credential".
- const initialCredChoice = () =>
- anthropicCreds.find((c) => c.is_default)?.id ??
- anthropicCreds[0]?.id ??
- NEW_CRED
+ // Everything model/credential-related follows the chosen runtime
+ // (claude→anthropic, codex→openai): the model list, the credential provider it
+ // filters to, and the key label.
+ const rt = getRuntime(runtime)
+ const providerCreds = (credentials ?? []).filter(
+ (c) => c.provider === rt.provider,
+ )
+ const hasDefault = providerCreds.some((c) => c.is_default)
+
+ // Lowest-friction default for a provider's creds: org default → first → "new".
+ const defaultCredFor = (creds: typeof providerCreds) =>
+ creds.find((c) => c.is_default)?.id ?? creds[0]?.id ?? NEW_CRED
const resetForm = () => {
setName('')
setPrompt('')
- setModel(DEFAULT_MODEL)
+ setRuntime(DEFAULT_RUNTIME)
+ setModel(defaultModelFor(DEFAULT_RUNTIME))
setCredChoice('')
setNewCredName('')
setNewCredKey('')
}
const openCreate = () => {
- setCredChoice(initialCredChoice())
+ setCredChoice(defaultCredFor(providerCreds))
setShowCreate(true)
}
- // Build options: existing creds + "New credential…".
+ // Switching runtime resets the dependent fields so we never submit an invalid
+ // (runtime, model) pair or an off-provider credential.
+ const onRuntimeChange = (value: string) => {
+ setRuntime(value)
+ const next = getRuntime(value)
+ setModel(next.models[0].value)
+ setCredChoice(
+ defaultCredFor(
+ (credentials ?? []).filter((c) => c.provider === next.provider),
+ ),
+ )
+ setNewCredName('')
+ setNewCredKey('')
+ }
+
+ // Build options: this runtime's provider creds + "New credential…".
const credOptions = [
- ...anthropicCreds.map((c) => ({
+ ...providerCreds.map((c) => ({
value: c.id,
label: `${c.name || 'Unnamed'}${c.last4 ? ` ·· ${c.last4}` : ''}${
c.is_default ? ' (default)' : ''
@@ -107,9 +121,9 @@ export default function Agents() {
if (credChoice === NEW_CRED) {
const cred = await createCredential({
key: newCredKey.trim(),
- provider: CRED_PROVIDER,
+ provider: rt.provider,
name: newCredName.trim() || undefined,
- is_default: !hasDefault, // first key becomes the org default
+ is_default: !hasDefault, // first key for this provider becomes its default
})
credentialId = cred.id
} else if (credChoice) {
@@ -119,7 +133,7 @@ export default function Agents() {
name: name.trim(),
prompt: prompt.trim(),
model,
- runtime: 'claude',
+ runtime,
credential: credentialId,
})
},
@@ -272,26 +286,35 @@ export default function Agents() {
/>
</Field>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
- <Field label="Model" htmlFor="agent-model">
+ <Field
+ label="Runtime"
+ htmlFor="agent-runtime"
+ description="The engine this agent runs on. Fixed once created."
+ >
<Select
- id="agent-model"
- value={model}
- onValueChange={setModel}
- options={MODELS}
+ id="agent-runtime"
+ value={runtime}
+ onValueChange={onRuntimeChange}
+ options={runtimeOptions}
/>
</Field>
<Field
- label="Runtime"
- htmlFor="agent-runtime"
- description="Codex and custom runtimes coming soon."
+ label="Model"
+ htmlFor="agent-model"
+ description={`Models available on the ${rt.label} runtime.`}
>
- <Input id="agent-runtime" value="Claude" disabled />
+ <Select
+ id="agent-model"
+ value={model}
+ onValueChange={setModel}
+ options={rt.models}
+ />
</Field>
</div>
<Field
label="Credential"
htmlFor="agent-cred"
- description="The Anthropic key this agent runs on. Reuse one from Credentials, or add a new one here."
+ description={`The ${rt.provider} key this agent runs on (matches the runtime). Reuse one from Credentials, or add a new one here.`}
>
<Select
id="agent-cred"
@@ -312,7 +335,7 @@ export default function Agents() {
/>
</Field>
<Field
- label="Anthropic API key"
+ label={rt.keyLabel}
htmlFor="new-cred-key"
description="Encrypted in a dedicated secret store."
>
@@ -321,7 +344,7 @@ export default function Agents() {
type="password"
value={newCredKey}
onChange={(e) => setNewCredKey(e.target.value)}
- placeholder="sk-ant-…"
+ placeholder={rt.keyPlaceholder}
/>
</Field>
</div>