fastmcp/tests/server/tasks
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
..
__init__.py [2.14] SEP-1686 tasks (#2378) 2025-12-04 20:10:35 -05:00
conftest.py Expose minimum_check_interval, reduce task pickup latency (#3500) 2026-03-14 16:08:28 -04:00
test_concurrent_dependencies.py Unify background task context forwarding, fix concurrent dependency bugs (#3710) 2026-04-03 10:48:27 -04:00
test_context_background_task.py Unify background task context forwarding, fix concurrent dependency bugs (#3710) 2026-04-03 10:48:27 -04:00
test_custom_subclass_tasks.py fix: resolve Pyright "Module is not callable" on @tool, @resource, @prompt decorators (#3540) 2026-03-17 18:11:42 -04:00
test_notifications.py Move relay logic to elicitation.py, fix related-task metadata key 2026-02-10 16:00:01 -05:00
test_progress_dependency.py Remove enable_docket setting; Docket is now always on 2025-12-05 11:40:04 -05:00
test_resource_task_meta_parameter.py fix: resolve Pyright "Module is not callable" on @tool, @resource, @prompt decorators (#3540) 2026-03-17 18:11:42 -04:00
test_server_tasks_parameter.py Expose minimum_check_interval, reduce task pickup latency (#3500) 2026-03-14 16:08:28 -04:00
test_sync_function_task_disabled.py Decorators return functions instead of component objects (#2856) 2026-01-12 21:58:07 -05:00
test_task_capabilities.py Version-check is_docket_available() to avoid transitive pydocket crash (#3807) 2026-04-09 21:52:21 -04:00
test_task_config.py fix: resolve Pyright "Module is not callable" on @tool, @resource, @prompt decorators (#3540) 2026-03-17 18:11:42 -04:00
test_task_dependencies.py Unify background task context forwarding, fix concurrent dependency bugs (#3710) 2026-04-03 10:48:27 -04:00
test_task_elicitation_relay.py Relay task elicitation through standard MCP protocol 2026-02-10 14:58:19 -05:00
test_task_meta_parameter.py fix: resolve Pyright "Module is not callable" on @tool, @resource, @prompt decorators (#3540) 2026-03-17 18:11:42 -04:00
test_task_metadata.py Move relay logic to elicitation.py, fix related-task metadata key 2026-02-10 16:00:01 -05:00
test_task_methods.py Expose minimum_check_interval, reduce task pickup latency (#3500) 2026-03-14 16:08:28 -04:00
test_task_mount.py fix: bump ty to >=0.0.29 and suppress new false positives (#3790) 2026-04-07 19:49:09 -04:00
test_task_prompts.py Refactor Client class into mixins and add timeout utilities (#2933) 2026-01-19 09:54:47 -05:00
test_task_protocol.py fix: stabilize task notification integration tests 2026-02-08 15:20:22 +01:00
test_task_proxy.py Expose minimum_check_interval, reduce task pickup latency (#3500) 2026-03-14 16:08:28 -04:00
test_task_resources.py Refactor Client class into mixins and add timeout utilities (#2933) 2026-01-19 09:54:47 -05:00
test_task_return_types.py fix: retry when LLM returns text instead of calling final_response (#3850) 2026-04-12 12:52:16 -04:00
test_task_security.py [2.14] SEP-1686 tasks (#2378) 2025-12-04 20:10:35 -05:00
test_task_status_notifications.py [2.14] SEP-1686 tasks (#2378) 2025-12-04 20:10:35 -05:00
test_task_tools.py Refactor Client class into mixins and add timeout utilities (#2933) 2026-01-19 09:54:47 -05:00
test_task_ttl.py [2.14] SEP-1686 tasks (#2378) 2025-12-04 20:10:35 -05:00