Codex P2 on #5549 flagged that the cycle-5 cursor-reset (efa43c4) keyed on every empty-status event, but generate_chat_completion_with_tools emits empty status events in five places, only two of which are real iteration boundaries: - Line 4497: emitted right before `continue` after a re-prompt / auto-continue. The next iteration starts a fresh assistant turn. BOUNDARY: reset cursor. - Line 4766: emitted right before `continue` after a tool call. The next iteration regenerates with tool results in history. BOUNDARY: reset cursor. - Line 4501: emitted at metadata-yield after normal streaming. Stream is about to end, no new iteration follows. NOT a boundary. - Line 4584: emitted in DRAINING-no-tool-call fallback path. Stream is about to end with buffered content_accum. NOT a boundary. - Line 4794: emitted at the final exit of the generator. NOT a boundary. Treating all five as boundaries gave every Anthropic-streaming response an extra content_block_stop + content_block_start pair around its final text and around every tool call. Fix by tagging the two real boundary sites with `"boundary": True` and tightening both the Anthropic emitter (`anthropic_compat.py`) and the OpenAI-compat tool path + Anthropic non-streaming path (`routes/inference.py`) to reset the cumulative-text cursor only when that flag is set. Plain empty-status events keep their existing badge- clear semantics on the frontend (`tool_status` SSE with content ""). Add two regression tests in `backend/tests/test_anthropic_messages.py::TestAnthropicStreamEmitter`: - test_boundary_flag_closes_block_and_resets_cursor: a boundary=True status closes the open text block and the next content delta streams from zero. - test_empty_status_without_boundary_does_not_close_block: a plain empty status leaves block_index unchanged and the next content delta is diffed against the previous text length. 107 tests pass across the four anthropic + trailing-plan test files. |
||
|---|---|---|
| .. | ||
| backend | ||
| frontend | ||
| src-tauri | ||
| __init__.py | ||
| install_llama_prebuilt.py | ||
| install_python_stack.py | ||
| LICENSE.AGPL-3.0 | ||
| setup.bat | ||
| setup.ps1 | ||
| setup.sh | ||
| Unsloth_Studio_Colab.ipynb | ||