Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions common/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2720,20 +2720,20 @@ static common_chat_params common_chat_params_init_laguna(const common_chat_templ
// "<assistant>\n" followed by the opening <think> (thinking enabled) or
// </think> (disabled). Consume it, then capture reasoning. The model's
// output therefore starts with the reasoning text (no leading <think>).
const std::string GEN_PROMPT = "<assistant>\n";
auto gen_prompt = p.literal("<assistant>") + p.optional(p.space());
auto head = p.eps();
if (extract_reasoning && inputs.enable_thinking) {
// The model normally closes reasoning with </think> before a tool
// call, but sometimes emits <tool_call> directly without it.
// Terminate reasoning on whichever marker comes first so the call is
// not swallowed into reasoning_content; consume </think> if present.
head = p.literal(GEN_PROMPT + THINK_START) +
head = gen_prompt + p.literal(THINK_START) +
p.reasoning(p.until_one_of({ THINK_END, CALL_START })) +
p.optional(p.literal(THINK_END));
} else if (extract_reasoning) {
head = p.literal(GEN_PROMPT + THINK_END);
head = gen_prompt + p.literal(THINK_END);
} else {
head = p.literal(GEN_PROMPT) +
head = gen_prompt +
p.optional(p.literal(THINK_START)) + p.optional(p.literal(THINK_END));
}

Expand Down