[PR #278] [CLOSED] serve: count_tokens, Anthropic thinking only when asked, STRATA_REQUEST_LINES, a relative exe #2544

Closed
opened 2026-11-04 02:01:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/278
Author: @sergqwer
Created: 9/30/2026
Status: ❌ Closed

Base: main ← Head: pr/serve-extras


📝 Commits (1)

  • 9eae7c4 serve: /v1/messages/count_tokens, Anthropic thinking only when asked, STRATA_REQUEST_LINES, a relative exe

📊 Changes

3 files changed (+66 additions, -1 deletions)

View changed files

📝 serve/frontend.py (+5 -0)
📝 serve/server.py (+44 -1)
📝 serve/test_server.py (+17 -0)

📄 Description

Summary

Four small server fixes, found by running Claude Code against the server and by starting a config with a relative
engine path:

  • POST /v1/messages/count_tokens answered 404; Claude Code asks it for its context figures. It now renders and
    tokenizes the request exactly as /v1/messages would, without running the model.
  • Anthropic thinking only when asked. A /v1/messages request without thinking (and without an effort) got the
    template's default, which thinks. Claude Code's helper calls (a ~60-token session title) came back with a thinking
    block and no text. Anthropic's thinking is opt-in, so such a request now renders with enable_thinking false. A
    config's reasoning_effort still applies; a request with thinking or an effort behaves as before.
  • STRATA_REQUEST_LINES=1: a thread follows the engine log and prints one line per request on stdout
    ([strata] request prompt P cached C output O ttft T ms total S ms prefill X tok/s decode Y tok/s), for supervisors
    that only see the server's stdout (a tray, llama-swap). Off by default.
  • A relative exe in the config failed in Windows' CreateProcess (WinError 2). It is now made absolute
    against the config's cwd, as the engine's own path already was.

Tests

Two new tests: count_tokens equals the input_tokens that /v1/messages reports for the same request, and the
request-line pattern parses the engine's summary. python -m unittest serve.test_server: 44 OK.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio


🔄 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/278 **Author:** [@sergqwer](https://github.com/sergqwer) **Created:** 9/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/serve-extras` --- ### 📝 Commits (1) - [`9eae7c4`](https://github.com/Niko1221/Strata/commit/9eae7c4fa89a5f87db3ac6a2ba9697a49aba9ca6) serve: /v1/messages/count_tokens, Anthropic thinking only when asked, STRATA_REQUEST_LINES, a relative exe ### 📊 Changes **3 files changed** (+66 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `serve/frontend.py` (+5 -0) 📝 `serve/server.py` (+44 -1) 📝 `serve/test_server.py` (+17 -0) </details> ### 📄 Description ## Summary Four small server fixes, found by running Claude Code against the server and by starting a config with a relative engine path: - **`POST /v1/messages/count_tokens`** answered 404; Claude Code asks it for its context figures. It now renders and tokenizes the request exactly as `/v1/messages` would, without running the model. - **Anthropic thinking only when asked.** A `/v1/messages` request without `thinking` (and without an effort) got the template's default, which thinks. Claude Code's helper calls (a ~60-token session title) came back with a thinking block and no text. Anthropic's thinking is opt-in, so such a request now renders with `enable_thinking` false. A config's `reasoning_effort` still applies; a request with `thinking` or an effort behaves as before. - **`STRATA_REQUEST_LINES=1`**: a thread follows the engine log and prints one line per request on stdout (`[strata] request prompt P cached C output O ttft T ms total S ms prefill X tok/s decode Y tok/s`), for supervisors that only see the server's stdout (a tray, llama-swap). Off by default. - **A relative `exe`** in the config failed in Windows' `CreateProcess` (WinError 2). It is now made absolute against the config's `cwd`, as the engine's own path already was. ## Tests Two new tests: `count_tokens` equals the `input_tokens` that `/v1/messages` reports for the same request, and the request-line pattern parses the engine's summary. `python -m unittest serve.test_server`: 44 OK. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:01:12 +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#2544
No description provided.