Skip to content

Commit 25a8c38

Browse files
Merge pull request #3 from Grigory-Rylov/fix/system_prompt_lang
fix(core, opencode): add language consistency instructions to synthetic messages
2 parents 6a827a9 + 296ffeb commit 25a8c38

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

packages/core/src/session/runner/to-llm-message.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ ${message.summary}
137137
<recent-context>
138138
${message.recent}
139139
</recent-context>
140-
</conversation-checkpoint>`,
140+
</conversation-checkpoint>
141+
142+
Continue responding in the same language as the conversation.`,
141143
metadata: message.metadata,
142144
}),
143145
]

packages/opencode/src/session/compaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ export const layer = Layer.effect(
504504
(input.overflow
505505
? "The previous request exceeded the provider's size limit due to large media attachments. The conversation was compacted and media files were removed from context. If the user was asking about attached images or files, explain that the attachments were too large to process and suggest they try again with smaller or fewer files.\n\n"
506506
: "") +
507-
"Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed."
507+
"Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed. Respond in the same language as the conversation."
508508
yield* session.updatePart({
509509
id: PartID.ascending(),
510510
messageID: continueMsg.id,

packages/opencode/src/session/message-v2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ export const toModelMessagesEffect = Effect.fnUntraced(function* (
239239
if (part.type === "compaction") {
240240
userMessage.parts.push({
241241
type: "text",
242-
text: "What did we do so far?",
242+
text: "What did we do so far? Respond in the same language as the conversation.",
243243
})
244244
}
245245
if (part.type === "subtask") {
246246
userMessage.parts.push({
247247
type: "text",
248-
text: "The following tool was executed by the user",
248+
text: "The following tool was executed by the user. Continue in the same language as the conversation.",
249249
})
250250
}
251251
}

packages/opencode/src/session/prompt.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ export const layer = Layer.effect(
427427
messageID: summaryUserMsg.id,
428428
sessionID,
429429
type: "text",
430-
text: "Summarize the task tool output above and continue with your task.",
430+
text: "Summarize the task tool output above and continue with your task. Respond in the same language as the conversation.",
431431
synthetic: true,
432432
} satisfies SessionV1.TextPart)
433433
})
@@ -465,7 +465,7 @@ export const layer = Layer.effect(
465465
id: PartID.ascending(),
466466
messageID: userMsg.id,
467467
sessionID: input.sessionID,
468-
text: "The following tool was executed by the user",
468+
text: "The following tool was executed by the user. Continue in the same language as the conversation.",
469469
synthetic: true,
470470
}
471471
yield* sessions.updatePart(userPart)
@@ -1315,7 +1315,7 @@ export const layer = Layer.effect(
13151315
"The user sent the following message:",
13161316
p.text,
13171317
"",
1318-
"Please address this message and continue with your tasks.",
1318+
"Please address this message and continue with your tasks. Respond in the same language as the user's message.",
13191319
"</system-reminder>",
13201320
].join("\n")
13211321
}

0 commit comments

Comments
 (0)