Unverified 提交 dd5dcda6 authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

fix: use user message instead of assistant prefill for continuation retry (#3027)

## Summary - Non-Anthropic providers (OpenAI, Google, Ollama, etc.) error with "The model does not support assistant message prefill" when the unclosed `dyad-write` continuation retry triggers - The continuation logic was using an assistant message as the last message (prefill pattern), which only Anthropic supports - Replaced with a user message that includes the partial response and asks the model to continue where it left off ## Test plan - Use a non-Anthropic provider (e.g. OpenAI, Gemini) in build mode - Trigger a response that produces an unclosed `<dyad-write>` tag (e.g. a large file write that gets cut off) - Verify the continuation retry no longer errors and the model completes the response 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/3027" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --------- Co-authored-by: 's avatarClaude Opus 4.6 (1M context) <noreply@anthropic.com>
上级 4d7fa151
......@@ -132,3 +132,8 @@ role: assistant
message: START OF MESSAGE
<dyad-write path="src/new-file.ts" description="this file will be partially written">
const a = "[[STRING_TO_BE_FINISHED]]
===
role: user
message: Your previous response did not finish completely. Continue exactly where you left off without any preamble.
\ No newline at end of file
......@@ -1453,10 +1453,18 @@ ${formattedSearchReplaceIssues}`,
continuationAttempts++;
const { fullStream: contStream } = await simpleStreamText({
// Build messages: replay history then pre-fill assistant with current partial.
// Build messages: replay history, then ask the model to continue from the partial response.
chatMessages: [
...chatMessages,
{ role: "assistant", content: fullResponse },
{
role: "assistant",
content: fullResponse,
},
{
role: "user",
content:
"Your previous response did not finish completely. Continue exactly where you left off without any preamble.",
},
],
modelClient,
files: files,
......
......@@ -59,7 +59,8 @@ export const createChatCompletionHandler =
if (
!localAgentFixture &&
(userTextContent.includes("incomplete todo(s)") ||
userTextContent.includes("previous response stream was interrupted"))
userTextContent.includes("previous response stream was interrupted") ||
userTextContent.includes("did not finish completely"))
) {
for (const msg of userMessages) {
const textContent = getTextContent(msg);
......@@ -334,11 +335,13 @@ export default Index;
}
}
// Continuation requests: the partial assistant output is in a preceding assistant
// message, then a user message asks to continue ("did not finish completely").
// Check any message for the marker. See chat_stream_handlers continuation prompt.
if (
lastMessage &&
lastMessage.content &&
typeof lastMessage.content === "string" &&
lastMessage.content.trim().endsWith("[[STRING_TO_BE_FINISHED]]")
messages.some((m: any) =>
getTextContent(m).includes("[[STRING_TO_BE_FINISHED]]"),
)
) {
messageContent = `[[STRING_IS_FINISHED]]";</dyad-write>\nFinished writing file.`;
messageContent += "\n\n" + generateDump(req);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论