Skip to content

Commit 859e496

Browse files
committed
fix: Remove synthetic prompt logic, use the prefill feature by sending the conversation payload ending with assistant message
1 parent c7e23c7 commit 859e496

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

tools/server/webui/src/lib/stores/chat.svelte.ts

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,20 +1733,6 @@ class ChatStore {
17331733

17341734
/**
17351735
* Continues generation for an existing assistant message
1736-
* Appends new content to the existing message without branching
1737-
*
1738-
* **Important Implementation Details:**
1739-
* - Sends a synthetic "continue" prompt to the API that is NOT persisted to the database
1740-
* - This creates intentional divergence: API sees the prompt, database does not
1741-
* - The synthetic prompt instructs the model to continue from where it left off
1742-
* - Original message content is fetched from database to ensure accuracy after stops/edits
1743-
* - New content is appended to the original message in-place (no branching)
1744-
*
1745-
* **Data Consistency Note:**
1746-
* The conversation history in the database will not include the synthetic "continue" prompt.
1747-
* This is by design - the prompt is a UI affordance, not part of the conversation content.
1748-
* Export/import will preserve the actual conversation without synthetic prompts.
1749-
*
17501736
* @param messageId - The ID of the assistant message to continue
17511737
*/
17521738
async continueAssistantMessage(messageId: string): Promise<void> {
@@ -1796,33 +1782,17 @@ class ChatStore {
17961782
// Get conversation context up to (but not including) the message to continue
17971783
const conversationContext = this.activeMessages.slice(0, messageIndex);
17981784

1799-
// Add a synthetic "continue" prompt to signal continuation
1800-
// We check if original content ends with whitespace to preserve it in the instruction
1801-
const endsWithWhitespace = /\s$/.test(originalContent);
1802-
const continueInstruction = endsWithWhitespace
1803-
? 'Continue your response. Start directly without adding extra spacing.'
1804-
: 'Continue your response from where you left off.';
1805-
1806-
const continuePrompt: ApiChatMessageData = {
1807-
role: 'user',
1808-
content: continueInstruction
1809-
};
1810-
1811-
// Build context: all previous messages + assistant message + synthetic user prompt
1812-
// The user prompt is only sent to the API, not saved to the database
18131785
const contextWithContinue = [
18141786
...conversationContext.map((msg) => {
18151787
if ('id' in msg && 'convId' in msg && 'timestamp' in msg) {
18161788
return msg as DatabaseMessage & { extra?: DatabaseMessageExtra[] };
18171789
}
1818-
18191790
return msg as ApiChatMessageData;
18201791
}),
18211792
{
18221793
role: 'assistant' as const,
18231794
content: originalContent
1824-
},
1825-
continuePrompt
1795+
}
18261796
];
18271797

18281798
let appendedContent = '';

0 commit comments

Comments
 (0)