[PR #1623] [CLOSED] fix(serve): make context overflow errors recognizable #3567

Closed
opened 2026-11-07 14:42:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1623
Author: @hulkbig
Created: 10/8/2026
Status: ❌ Closed

Base: main ← Head: fix/context-overflow-messages-1615-20261009


📝 Commits (1)

  • 9ea8189 fix(serve): make context overflow errors recognizable

📊 Changes

2 files changed (+121 additions, -2 deletions)

View changed files

📝 serve/server.py (+4 -2)
➕ serve/test_context_overflow.py (+117 -0)

📄 Description

Fixes #1615.

Summary

Prefix both context-overflow errors with request exceeds the context window: so client overflow classifiers can recognize them. The existing token counts, no-truncation wording, and max_tokens / fit_max_tokens guidance remain intact.

What changed

  • serve/server.py: message-only change in the two rejection branches. Admission rules, the eight-token context slack, fitting behavior, HTTP 400 status, and response schemas are unchanged.
  • serve/test_context_overflow.py: CPU-only HTTP regressions cover both branches through chat completions, Messages, and Responses, with streaming requested and disabled. Coverage includes the reported 150,722-token prompt / 131,072-token context, fitting enabled and disabled, one-token/zero-token room boundaries, and preserved prompt/budget limits. Rejected requests never reach generation.

Validation

  • python -m unittest serve.test_context_overflow serve.test_server.MaxTokens serve.test_server.FitMaxTokens serve.test_responses serve.test_request_hardening -q: 60 tests, zero failures/errors, one skip. Independently rerun with the same result.
  • Replaying the new regression tests on unmodified fb58e0d produces 30 failed subtests for the missing phrase.
  • Compared 24 actual HTTP error payloads before/after: the added message prefix is the only payload difference.
  • Executed the unmodified Pi overflow classifier at 6fb2e7815167e6b19006fc526d1a5d0f5f998787 (package version 1.1.0, source blob 2c0a5dc6e7f51a092545e0304248d7f264a03c98) using Node 24.19.0. All 48 baseline message forms were unrecognized; all 48 fixed forms were recognized (24 HTTP payloads, each as bare and HTTP-400-prefixed text). Two unrelated-error negative controls remained false.
  • Production AST comparison is identical after removing the two added prefixes.

Test limits

python -m unittest discover -s serve -p 'test_*.py' -q ran 596 tests with one error and 11 skips. The error is test_server.AmdTelemetry.test_readings: this host returns None from psutil.disk_io_counters(), causing AttributeError: 'NoneType' object has no attribute 'read_bytes' at serve/telemetry.py:311. The same error reproduces on untouched fb58e0d with python -m unittest serve.test_server.AmdTelemetry.test_readings -v. No shim was applied.

Validation establishes recognition by that pinned Pi classifier. It does not exercise a full Pi agent compaction/retry cycle; the issue does not specify its Pi version.


🔄 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/1623 **Author:** [@hulkbig](https://github.com/hulkbig) **Created:** 10/8/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/context-overflow-messages-1615-20261009` --- ### 📝 Commits (1) - [`9ea8189`](https://github.com/Niko1221/Strata/commit/9ea818912b74d15cc5b24175eda7eefa4e047340) fix(serve): make context overflow errors recognizable ### 📊 Changes **2 files changed** (+121 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+4 -2) ➕ `serve/test_context_overflow.py` (+117 -0) </details> ### 📄 Description Fixes #1615. ## Summary Prefix both context-overflow errors with `request exceeds the context window: ` so client overflow classifiers can recognize them. The existing token counts, no-truncation wording, and `max_tokens` / `fit_max_tokens` guidance remain intact. ## What changed - `serve/server.py`: message-only change in the two rejection branches. Admission rules, the eight-token context slack, fitting behavior, HTTP 400 status, and response schemas are unchanged. - `serve/test_context_overflow.py`: CPU-only HTTP regressions cover both branches through chat completions, Messages, and Responses, with streaming requested and disabled. Coverage includes the reported 150,722-token prompt / 131,072-token context, fitting enabled and disabled, one-token/zero-token room boundaries, and preserved prompt/budget limits. Rejected requests never reach generation. ## Validation - `python -m unittest serve.test_context_overflow serve.test_server.MaxTokens serve.test_server.FitMaxTokens serve.test_responses serve.test_request_hardening -q`: 60 tests, zero failures/errors, one skip. Independently rerun with the same result. - Replaying the new regression tests on unmodified `fb58e0d` produces 30 failed subtests for the missing phrase. - Compared 24 actual HTTP error payloads before/after: the added message prefix is the only payload difference. - Executed the unmodified [Pi overflow classifier](https://github.com/earendil-works/pi/blob/6fb2e7815167e6b19006fc526d1a5d0f5f998787/packages/ai/src/utils/overflow.ts) at `6fb2e7815167e6b19006fc526d1a5d0f5f998787` (package version 1.1.0, source blob `2c0a5dc6e7f51a092545e0304248d7f264a03c98`) using Node 24.19.0. All 48 baseline message forms were unrecognized; all 48 fixed forms were recognized (24 HTTP payloads, each as bare and HTTP-400-prefixed text). Two unrelated-error negative controls remained false. - Production AST comparison is identical after removing the two added prefixes. ## Test limits `python -m unittest discover -s serve -p 'test_*.py' -q` ran 596 tests with one error and 11 skips. The error is `test_server.AmdTelemetry.test_readings`: this host returns `None` from `psutil.disk_io_counters()`, causing `AttributeError: 'NoneType' object has no attribute 'read_bytes'` at `serve/telemetry.py:311`. The same error reproduces on untouched `fb58e0d` with `python -m unittest serve.test_server.AmdTelemetry.test_readings -v`. No shim was applied. Validation establishes recognition by that pinned Pi classifier. It does not exercise a full Pi agent compaction/retry cycle; the issue does not specify its Pi version. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:42:22 +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#3567
No description provided.