]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
server : add thinking content blocks to Anthropic Messages API (#18551)
authorR <redacted>
Tue, 6 Jan 2026 15:17:13 +0000 (16:17 +0100)
committerGitHub <redacted>
Tue, 6 Jan 2026 15:17:13 +0000 (16:17 +0100)
commit3d26a09dc7b1a7c13da57fdd26d1cf22efa81229
treeb0a9fbbb3abc518105a1f8173a2e4960e7a72e1e
parentbd2a93d4753c4f00443f561ee039220283016ee8
server : add thinking content blocks to Anthropic Messages API (#18551)

* server : add thinking content blocks to Anthropic Messages API

Add support for returning reasoning/thinking content in Anthropic API
responses when using models with --reasoning-format deepseek and the
thinking parameter enabled.

- Non-streaming: adds thinking block before text in content array
- Streaming: emits thinking_delta events with correct block indices
- Partial streaming: tracks reasoning state across chunks via
  anthropic_has_reasoning member variable

Tested with bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF model.

* server : fix Anthropic API streaming for thinking content blocks

Add signature field and fix duplicate content_block_start events in
Anthropic Messages API streaming responses for reasoning models.

* server: refactor Anthropic streaming state to avoid raw pointer

Replace raw pointer to task_result_state with direct field copies:
- Copy state fields in update() before processing chunk
- Use local copies in to_json_anthropic() instead of dereferencing
- Pre-compute state updates for next chunk in update()

This makes the data flow clearer and avoids unsafe pointer patterns.
tools/server/server-task.cpp
tools/server/server-task.h
tools/server/tests/unit/test_compat_anthropic.py