Pull requests / #3126

#3126 test+guard: a call for a tool the request never offered stays text (#3075)

open · @ctr-137 · 0 comentarios · En GitHub

Server & APIWindows

Descripción

## What it changes

- `serve/frontend.py:1285` — the content state's call scan is gated on the declared tools, the way the reasoning-state scan at `:1246` already is. A request that declares nothing can no longer come back with `tool_calls` and an empty `content`.
- `serve/test_server.py` — `ForcedToolChoice.test_a_call_the_request_never_offered_stays_text`, the answer side that was missing: after `</think>` the model writes a complete, well-formed call for a tool the request never offered, checked for `tools` absent, `tools: []` and `tool_choice: "none"`, streamed and not (6 subtests). On the unpatched tree all 6 fail.
- Two existing tests that encoded the old behaviour, moved to the new rule: `serve/test_mcp.py` (`test_plain_requests_get_no_mcp_tools`) now expects `stop` and the call as content, and `serve/test_parser_call_scan.py` declares a tool because that test measures the structural walk, not the no-tools rule. Their intent is unchanged.

## What it leaves alone

The second gap in #3075 — a call naming a function outside a *declared* set — is not touched. It needs a change in `_scan()` at the `ss == "name"` step, and I did not guess at it.

## How I checked

- New test: 6 subtests fail on the unpatched tree, pass with the guard.
- `python -m unittest serve.test_parser_call_scan serve.test_mcp serve.test_server.ForcedToolChoice`: 37 tests, OK.
- Full `serve` suite: 849 tests. On this machine three modules fail before and after the change alike — `test_winjob` and `test_keepawake` (Windows job object and timing) and `test_responses` (intermittently: three baseline runs and three patched runs all failed, the same two tests). Nothing else changed.

## Open point

The guard is a rule decision, not just a one-line fix: `serve/test_mcp.py:329` read *"returned to the client as always"*, so today's behaviour was written down as intended. If that is the intent, the new test should assert `tool_calls` instead, and the guard should not land. Flagged on the issue: https://github.com/Niko1221/Strata/issues/3075#issuecomment-6254752209

🤖 Generated with [Claude Code](https://claude.com/claude-code)

En el sitio

Enlaces a install, modelos, releases.