Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/opencode/src/session/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ export namespace LLM {
const [language, cfg] = await Promise.all([Provider.getLanguage(input.model), Config.get()])

const system = SystemPrompt.header(input.model.providerID)
const assistantInfo = await SystemPrompt.assistantInfo(input.model)
system.push(
[
assistantInfo,
// use agent prompt otherwise provider prompt
...(input.agent.prompt ? [input.agent.prompt] : SystemPrompt.provider(input.model)),
// any custom prompt passed into this call
Expand Down
9 changes: 8 additions & 1 deletion packages/opencode/src/session/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Ripgrep } from "../file/ripgrep"
import { Global } from "../global"
import { Filesystem } from "../util/filesystem"
import { Config } from "../config/config"
import { Installation } from "../installation"
import { Provider } from "../provider/provider"

import { Instance } from "../project/instance"
import path from "path"
Expand All @@ -14,14 +16,19 @@ import PROMPT_GEMINI from "./prompt/gemini.txt"
import PROMPT_ANTHROPIC_SPOOF from "./prompt/anthropic_spoof.txt"

import PROMPT_CODEX from "./prompt/codex.txt"
import type { Provider } from "@/provider/provider"

export namespace SystemPrompt {
export function header(providerID: string) {
if (providerID.includes("anthropic")) return [PROMPT_ANTHROPIC_SPOOF.trim()]
return []
}

export async function assistantInfo(model?: Provider.Model) {
if (!model) return `You are running in OpenCode v${Installation.VERSION}, the best coding agent on the planet.`
const provider = await Provider.getProvider(model.providerID)
return `You are ${model.name} (${provider.name}: ${model.id}) running in OpenCode v${Installation.VERSION}, the best coding agent on the planet.`
}

export function provider(model: Provider.Model) {
if (model.api.id.includes("gpt-5")) return [PROMPT_CODEX]
if (model.api.id.includes("gpt-") || model.api.id.includes("o1") || model.api.id.includes("o3"))
Expand Down