[PR #3356] [CLOSED] [Other] Add assistant prefill support for chat completions #4587

Closed
opened 2026-11-07 15:37:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3356
Author: @j-luwierski
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: feat/assistant-prefix-rebased


📝 Commits (2)

  • 8ca3e17 serve: "assistant_prefix" continues the assistant's turn from where the client starts it
  • baccd43 serve: assistant_prefix hardening - exact text, tools, structured output, token text

📊 Changes

4 files changed (+331 additions, -7 deletions)

View changed files

📝 docs/DETAILS.md (+25 -0)
📝 serve/frontend.py (+15 -2)
📝 serve/server.py (+42 -5)
📝 serve/test_server.py (+249 -0)

📄 Description

Problem and result: Strata's chat APIs could not continue generation from a partially written assistant turn. Requests can now provide an optional assistant_prefix; Strata prefills that text and returns only the generated continuation. When the field is absent, null, or empty, existing behavior is unchanged.

Related discussion: Replacement for #1189. Its /reopen check passed, but GitHub would not reopen that closed pull request.

Approach: Render the supplied prefix as the unfinished final assistant turn in the Python serving layer. Preserve the prefix text and existing tool, structured-output, streaming, reasoning, and context handling. Document the request field and add regression coverage.

Validation (revision baccd430, rebased on main e88ee39d / 0.2.0-beta; Linux):

Passed:

  • git diff --check origin/main...HEAD — clean.
  • python3 -m py_compile serve/frontend.py serve/server.py — passed.
  • uv run --with-requirements requirements.txt python -m unittest serve.test_server.AssistantPrefix — 20 tests, OK (Python 3.12.14).
  • uv run --with-requirements requirements.txt python -m unittest serve.test_server — 361 tests in 104.6 seconds, OK (Python 3.12.14).

Failed:

  • python3 -m unittest serve.test_server.AssistantPrefix with the system Python — could not import jinja2 because it is not installed in that interpreter. The same tests passed using the repository's pinned dependencies via uv.

Not run:

  • Live model/GPU validation on the rebased revision. This change does not touch C++, CUDA, HIP, or SYCL code.

Limits: The rebased revision has mock-engine test coverage; hardware behavior has not been revalidated on this revision.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3356 **Author:** [@j-luwierski](https://github.com/j-luwierski) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/assistant-prefix-rebased` --- ### 📝 Commits (2) - [`8ca3e17`](https://github.com/Niko1221/Strata/commit/8ca3e1735a448e8b949f399c792b48400d298240) serve: "assistant_prefix" continues the assistant's turn from where the client starts it - [`baccd43`](https://github.com/Niko1221/Strata/commit/baccd430d1f8866620de342d3fe530667d638e69) serve: assistant_prefix hardening - exact text, tools, structured output, token text ### 📊 Changes **4 files changed** (+331 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+25 -0) 📝 `serve/frontend.py` (+15 -2) 📝 `serve/server.py` (+42 -5) 📝 `serve/test_server.py` (+249 -0) </details> ### 📄 Description Problem and result: Strata's chat APIs could not continue generation from a partially written assistant turn. Requests can now provide an optional assistant_prefix; Strata prefills that text and returns only the generated continuation. When the field is absent, null, or empty, existing behavior is unchanged. Related discussion: Replacement for [#1189](https://github.com/Niko1221/Strata/pull/1189). Its /reopen check passed, but GitHub would not reopen that closed pull request. Approach: Render the supplied prefix as the unfinished final assistant turn in the Python serving layer. Preserve the prefix text and existing tool, structured-output, streaming, reasoning, and context handling. Document the request field and add regression coverage. Validation (revision baccd430, rebased on main e88ee39d / 0.2.0-beta; Linux): Passed: - git diff --check origin/main...HEAD — clean. - python3 -m py_compile serve/frontend.py serve/server.py — passed. - uv run --with-requirements requirements.txt python -m unittest serve.test_server.AssistantPrefix — 20 tests, OK (Python 3.12.14). - uv run --with-requirements requirements.txt python -m unittest serve.test_server — 361 tests in 104.6 seconds, OK (Python 3.12.14). Failed: - python3 -m unittest serve.test_server.AssistantPrefix with the system Python — could not import jinja2 because it is not installed in that interpreter. The same tests passed using the repository's pinned dependencies via uv. Not run: - Live model/GPU validation on the rebased revision. This change does not touch C++, CUDA, HIP, or SYCL code. Limits: The rebased revision has mock-engine test coverage; hardware behavior has not been revalidated on this revision. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:37:39 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4587
No description provided.