Skip to content

fix(examples): preserve assistant content across streamed tool rounds - #726

Open
roli-lpci wants to merge 1 commit into
ollama:mainfrom
roli-lpci:fix/streamed-tool-history
Open

fix(examples): preserve assistant content across streamed tool rounds#726
roli-lpci wants to merge 1 commit into
ollama:mainfrom
roli-lpci:fix/streamed-tool-history

Conversation

@roli-lpci

Copy link
Copy Markdown

The GPT-OSS streaming tool example prints assistant content chunks but never adds them to the content accumulator. When a response includes text followed by a tool call, the next request therefore replays an assistant message with empty content.

This accumulates the streamed content before storing the assistant message. A deterministic test runs the example with a mocked two-round stream and checks that the next request preserves both text chunks before the tool result. No model, credentials, or network requests are needed by the test.

Validation:

  • The regression fails against the unchanged example ('' instead of Checking London.) and passes with the fix.
  • uv run --python 3.11 --with pytest --with pytest-httpserver --with pytest-anyio python -m pytest -q ollama tests: 103 passed.
  • ruff check . and git diff --check: passed.
  • Independent local diff review: no findings.

Prepared with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant