mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-24 14:34:17 +02:00
* Cap consecutive final_response validation retries to 3 Previously, when the LLM repeatedly called final_response with data that failed validation, the retry loop would continue up to 100 times (the shared max_iterations limit), wasting tokens on a model that cannot satisfy the schema. Add _MAX_VALIDATION_RETRIES (default 3) that caps consecutive validation failures. The counter resets when the LLM calls other tools (not final_response), so the cap only applies to consecutive failures. Fixes #3848 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add tests for consecutive validation retry cap Tests cover: - Validation failures within cap followed by success - Consecutive validation failures exceeding cap (raises RuntimeError) - Counter reset when LLM calls other tools between validation failures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Slim down validation retry cap tests Reduce boilerplate with helper functions. Simplify counter-reset test from 5 calls to 4. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix static analysis: move imports to module level and format Move CreateMessageResultWithTools and ToolUseContent imports to the top of the test file so ty can resolve the names used in return-type annotations of the helper functions. Also fix ruff import sorting and formatting issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Align validation retry semantics with text-response retries Change `>=` to `>` so _MAX_VALIDATION_RETRIES means "number of retries after the initial attempt" (total = N+1), matching the convention used by _MAX_TEXT_RESPONSE_RETRIES in the text-response retry path. Before: _MAX=3 meant 3 total attempts (>= comparison) After: _MAX=3 means 1 initial + 3 retries = 4 total (> comparison) 🤖 Generated with Claude Code Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| auth | ||
| client | ||
| sampling | ||
| tasks | ||
| telemetry | ||
| transports | ||
| __init__.py | ||
| test_elicitation.py | ||
| test_elicitation_enums.py | ||
| test_logs.py | ||
| test_notifications.py | ||
| test_oauth_callback_race.py | ||
| test_oauth_callback_xss.py | ||
| test_openapi.py | ||
| test_progress.py | ||
| test_roots.py | ||
| test_sampling.py | ||
| test_sampling_result_types.py | ||
| test_sampling_tool_loop.py | ||
| test_sse.py | ||
| test_stdio.py | ||
| test_streamable_http.py | ||