Skip to content

Commit 8e8b163

Browse files
committed
feat: send full conversation history with each request so the model has context
Previously every send was a single-turn POST: the agent only saw the new user message, so it couldn't remember the rest of the chat. Now the frontend bundles the active conversation's full message history (filtered to user+assistant turns, dropping the thinking placeholder) into a 'messages' array on the request payload. The handler receives this and forwards it to vLLM as a multi-turn chat — system prompt, prior turns, then current user message (with any attached image parts bound to that last user message). Backend already supports this in v1.1.0 via the new schema (either 'prompt' or 'messages' is accepted).
1 parent 555bfc9 commit 8e8b163

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ async function sendPrompt(promptText, images) {
300300
setBusy(true);
301301
try {
302302
const client = await getClient();
303-
const payload = { prompt: promptText, max_tokens: state.maxTokens };
303+
const history = c.messages
304+
.filter((m) => (m.role === 'user' || m.role === 'assistant') && !m.thinking)
305+
.map((m) => ({ role: m.role, content: m.content }));
306+
const payload = { messages: history, max_tokens: state.maxTokens };
304307
const parts = [textPart(JSON.stringify(payload), 'request')];
305308
for (let i = 0; i < (images || []).length; i++) {
306309
const bin = atob(images[i]);

0 commit comments

Comments
 (0)