fastmcp/tests/client
Bill Easton f26c8fad3e
fix: retry when LLM returns text instead of calling final_response (#3850)
* Retry when LLM returns text instead of calling final_response tool

Instead of raising RuntimeError immediately when the LLM returns a text
response instead of calling the `final_response` tool for structured
output, retry up to 3 times with an explicit nudge message asking the
model to use the tool. This mirrors the existing retry behavior for
validation errors but with a separate, smaller cap.

Fixes #3847

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add tests for text response retry logic

Tests cover:
- Text response followed by successful final_response (retry works)
- Text response exceeding max retries (raises RuntimeError)
- Nudge message appended to history on retry
- No retry when result_type is None (text is valid)

Addresses review feedback from PR review tool (v1 flagged missing tests as high severity).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Slim down text response retry tests

Remove test_nudge_message_in_history (implementation detail).
Reduce boilerplate in remaining 3 tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix ruff format

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 12:52:16 -04:00
..
auth fix: store absolute token expiry to prevent stale expires_in on reload (#3572) 2026-03-21 12:12:50 -04:00
client Harden client tool result error handling (#3778) 2026-04-08 13:57:10 -04:00
sampling fix: strip title fields from tool schemas for Gemini 2.5 Flash compatibility (#3861) 2026-04-12 12:51:49 -04:00
tasks Expose minimum_check_interval, reduce task pickup latency (#3500) 2026-03-14 16:08:28 -04:00
telemetry Fix ty 0.0.17 diagnostics and bump lockfile 2026-02-16 16:13:38 -05:00
transports fix: bump ty to >=0.0.29 and suppress new false positives (#3790) 2026-04-07 19:49:09 -04:00
__init__.py clean up test inits 2025-05-31 19:32:08 -04:00
test_elicitation.py Update ty ignore comments for 0.0.25 compatibility (#3614) 2026-03-24 20:26:26 -04:00
test_elicitation_enums.py Update ty ignore comments for 0.0.25 compatibility (#3614) 2026-03-24 20:26:26 -04:00
test_logs.py Update ty ignore comments for 0.0.25 compatibility (#3614) 2026-03-24 20:26:26 -04:00
test_notifications.py Remove sync notification infrastructure 2026-01-18 17:31:11 -05:00
test_oauth_callback_race.py Guard OAuth callback result from post-completion overwrites (#3417) 2026-03-07 11:41:00 -05:00
test_oauth_callback_xss.py Escape all HTML to prevent XSS attack (#2090) 2025-10-14 12:30:21 -07:00
test_openapi.py Move OpenAPI to providers/openapi submodule (#2672) 2025-12-22 11:13:33 -05:00
test_progress.py Guard default progress handler against zero totals (#3432) 2026-03-07 11:41:11 -05:00
test_roots.py Add structured content & update almost all tests 2025-06-27 15:40:52 -04:00
test_sampling.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_sampling_result_types.py fix: retry when LLM returns text instead of calling final_response (#3850) 2026-04-12 12:52:16 -04:00
test_sampling_tool_loop.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_sse.py Bump tool sleep to actually validate timeout precedence 2026-03-02 13:50:29 -05:00
test_stdio.py fix: recover StdioTransport after subprocess exits (#3630) 2026-03-26 22:16:54 -04:00
test_streamable_http.py Fix ty 0.0.17 diagnostics and bump lockfile 2026-02-16 16:13:38 -05:00