|
1 | 1 | import { |
2 | | - metaPresetAppend, |
| 2 | + metaInstructions, |
3 | 3 | metaSystemPrompt, |
4 | 4 | type MetaRequestKind, |
5 | 5 | } from "./request-kind.js"; |
@@ -121,25 +121,35 @@ export type ClaudeCodePreset = { |
121 | 121 | }; |
122 | 122 |
|
123 | 123 | /** |
124 | | - * System prompt of a turn: always the Claude Code preset, with the meta |
125 | | - * instructions, the bridged-tool rules and the forwarded OpenCode context |
126 | | - * appended as they apply. `bridgedToolNames` is null when the turn runs |
127 | | - * without bridged tools. |
| 124 | + * Meta turns need none of Claude Code's coding instructions. A non-preset |
| 125 | + * system prompt is accepted on subscription credentials (checked on Haiku 4.5 |
| 126 | + * and Opus 5.5), and this one is 2-6k tokens smaller than the preset. |
128 | 127 | */ |
129 | | -export function claudeCodePreset( |
| 128 | +const UTILITY_SYSTEM_PROMPT = |
| 129 | + "You are a text generation helper running through the Claude Code harness. Return only the requested output."; |
| 130 | + |
| 131 | +/** |
| 132 | + * System prompt of a turn. Meta turns: the one-line utility prompt with |
| 133 | + * their instructions. Other turns: the Claude Code preset, with the |
| 134 | + * bridged-tool rules and the forwarded OpenCode context appended as they |
| 135 | + * apply. `bridgedToolNames` is null when the turn runs without bridged tools. |
| 136 | + */ |
| 137 | +export function turnSystemPrompt( |
130 | 138 | metaKind: MetaRequestKind, |
131 | 139 | messages: MessageLike[], |
132 | 140 | bridgedToolNames: string[] | null, |
133 | | -): ClaudeCodePreset { |
134 | | - const preset: ClaudeCodePreset = { type: "preset", preset: "claude_code" }; |
| 141 | +): ClaudeCodePreset | string { |
135 | 142 | if (metaKind) { |
136 | 143 | // V2 sends its summary instructions in the user turn; its system prompt is |
137 | 144 | // the agent's own, whose "# Your Model"/<env> sections get the request |
138 | 145 | // rejected as third-party usage. |
139 | 146 | const system = metaSystemPrompt(messages); |
140 | | - preset.append = metaPresetAppend(metaKind, V2_MODEL_MARKER.test(system) ? "" : system); |
141 | | - return preset; |
| 147 | + return [ |
| 148 | + UTILITY_SYSTEM_PROMPT, |
| 149 | + metaInstructions(metaKind, V2_MODEL_MARKER.test(system) ? "" : system), |
| 150 | + ].join("\n\n"); |
142 | 151 | } |
| 152 | + const preset: ClaudeCodePreset = { type: "preset", preset: "claude_code" }; |
143 | 153 | const context = systemContextForwardingEnabled() |
144 | 154 | ? openCodeSystemContext(messages) |
145 | 155 | : ""; |
|
0 commit comments