Skip to content

Commit 12cd48d

Browse files
committed
enhance context retention between tool calls, fix lints
1 parent 966184a commit 12cd48d

File tree

7 files changed

+27
-8
lines changed

7 files changed

+27
-8
lines changed

tools/server/public/index.html.gz

-1.42 MB
Binary file not shown.

tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessageThinkingBlock.svelte

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
import { buttonVariants } from '$lib/components/ui/button/index.js';
66
import { Card } from '$lib/components/ui/card';
77
import { config } from '$lib/stores/settings.svelte';
8+
import type { Snippet } from 'svelte';
89
910
interface Props {
1011
class?: string;
1112
hasRegularContent?: boolean;
1213
isStreaming?: boolean;
1314
reasoningContent: string | null;
15+
children?: Snippet;
1416
}
1517
1618
let {
1719
class: className = '',
1820
hasRegularContent = false,
1921
isStreaming = false,
20-
reasoningContent
22+
reasoningContent,
23+
children
2124
}: Props = $props();
2225
2326
const currentConfig = config();
@@ -72,9 +75,11 @@
7275
<div class="border-t border-muted px-3 pb-3">
7376
<div class="pt-3">
7477
<div class="text-xs leading-relaxed break-words whitespace-pre-wrap">
75-
<slot>
78+
{#if children}
79+
{@render children()}
80+
{:else}
7681
{reasoningContent ?? ''}
77-
</slot>
82+
{/if}
7883
</div>
7984
</div>
8085
</div>

tools/server/webui/src/lib/services/chat.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export class ChatService {
119119
messages: normalizedMessages.map((msg: ApiChatMessageData) => ({
120120
role: msg.role,
121121
content: msg.content,
122+
...(msg.reasoning_content ? { reasoning_content: msg.reasoning_content } : {}),
122123
...((msg as ApiChatCompletionRequestMessage).tool_call_id
123124
? { tool_call_id: (msg as ApiChatCompletionRequestMessage).tool_call_id }
124125
: {}),
@@ -602,6 +603,9 @@ export class ChatService {
602603
return {
603604
role: message.role as ChatRole,
604605
content: message.content,
606+
...(message.role === 'assistant' && message.thinking
607+
? { reasoning_content: message.thinking }
608+
: {}),
605609
// tool_call_id is only relevant for tool role messages
606610
...(message.toolCallId ? { tool_call_id: message.toolCallId } : {}),
607611
...(toolCalls ? { tool_calls: toolCalls } : {})
@@ -693,6 +697,9 @@ export class ChatService {
693697
return {
694698
role: message.role as ChatRole,
695699
content: contentParts,
700+
...(message.role === 'assistant' && message.thinking
701+
? { reasoning_content: message.thinking }
702+
: {}),
696703
...(message.toolCallId ? { tool_call_id: message.toolCallId } : {}),
697704
...(toolCalls ? { tool_calls: toolCalls } : {})
698705
};

tools/server/webui/src/lib/types/api.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ export interface ApiChatMessageData {
3535
role: ChatRole;
3636
content: string | ApiChatMessageContentPart[];
3737
timestamp?: number;
38+
/**
39+
* Optional reasoning/thinking content to be sent back to the server.
40+
*
41+
* llama-server accepts this non-OpenAI field and uses it to preserve the model's
42+
* internal "thinking" blocks across tool-call resumptions (notably for gpt-oss).
43+
*/
44+
reasoning_content?: string;
3845
tool_call_id?: string;
3946
tool_calls?: ApiChatCompletionToolCallDelta[];
4047
}
@@ -183,6 +190,7 @@ export interface ApiLlamaCppServerProps {
183190
export interface ApiChatCompletionRequestMessage {
184191
role: ChatRole;
185192
content: string | ApiChatMessageContentPart[];
193+
reasoning_content?: string;
186194
tool_call_id?: string;
187195
tool_calls?: ApiChatCompletionToolCallDelta[];
188196
}

tools/server/webui/tests/client/chatMessage.delete-merged-assistant.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ describe('ChatMessage delete for merged assistant messages', () => {
7575
conversationsStore.activeMessages = allMessages;
7676

7777
// Avoid touching IndexedDB by stubbing the store call used by getDeletionInfo.
78-
const originalGetConversationMessages = conversationsStore.getConversationMessages.bind(
79-
conversationsStore
80-
);
78+
const originalGetConversationMessages =
79+
conversationsStore.getConversationMessages.bind(conversationsStore);
8180
conversationsStore.getConversationMessages = async () => allMessages;
8281

8382
const onDelete = vi.fn();
@@ -111,4 +110,3 @@ describe('ChatMessage delete for merged assistant messages', () => {
111110
}
112111
});
113112
});
114-

tools/server/webui/tests/client/components/TestChatMessageWrapper.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
<ChatMessage message={props.message} onDelete={props.onDelete} />
1515
</Sidebar.Provider>
1616
</Tooltip.Provider>
17-

tools/server/webui/tests/e2e/tool-output-no-echo.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,6 @@ test('tool output does not echo tool arguments back to the model', async ({ page
137137
);
138138
expect(assistantWithToolCall).toBeTruthy();
139139
expect(JSON.stringify(assistantWithToolCall?.tool_calls ?? null)).toContain('LARGE_CODE_BEGIN');
140+
// Preserve the model's reasoning across tool-call resumptions (required for gpt-oss).
141+
expect(String(assistantWithToolCall?.reasoning_content ?? '')).toContain('reasoning-step-1');
140142
});

0 commit comments

Comments
 (0)