APIError is a ProviderError subclass, so it was caught by 'except ProviderError: raise'
and handled by provider_error_handler, bypassing the generic exception path that uses
getattr(e, 'status_code', 500). The test now uses RuntimeError with a dynamically-added
status_code attribute to actually test that fallback logic in routes.py.
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
The drain/put approach used get_nowait() and put_nowait(). Each
put_nowait() increments _unfinished_tasks without a corresponding
task_done(), permanently inflating the counter on every invocation.
Revert to reading the internal deque directly (list(self._queue._queue))
which does not mutate any queue state. This matches the approach used
in remove_from_queue.
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
- messaging/telegram.py: Remove unused type: ignore, fix retry_after typing
with isinstance(timedelta), use local app variable for None narrowing
- messaging/tree_data.py: Replace _queue._queue access with drain-and-restore
approach for get_queue_snapshot (avoids private API)
- tests/test_api.py: Use APIError instead of RuntimeError for status_code test
- tests/test_config.py: Use cast(Any, ...) for invalid validation tests
- tests/test_dependencies.py: Add isinstance check for NvidiaNimProvider
- tests/test_handler_markdown_and_status_edges.py: Use patch.object for
tree_queue method mocks
- tests/test_response_models.py: Add isinstance narrowing for content blocks,
use Literal list for stop_reason parametrization
- tests/test_restart_reply_restore.py: Use patch.object for enqueue mock
- tests/test_server_module.py: Use patch.object for uvicorn.run and
get_settings
- tests/test_telegram_edge_cases.py: Use patch.object for method mocks
- tests/test_tree_concurrency.py: Add None assertions for get_node/get_tree
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
- Assistant messages: build content string in block order (thinking+text interleaved)
- User messages: emit text before tool results when order is text→tool_result
- Response: add extract_think_content_interleaved() to preserve <think>...</think> order
- Add tests and docs for context preservation bugs
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
ContentBlockManager already declares task_arg_buffer, task_args_emitted,
tool_ids. Remove defensive getattr/isinstance checks from _process_tool_call
and _flush_task_arg_buffers.
Update test_subagent_interception to set task_arg_buffer, task_args_emitted,
tool_ids on mock so it behaves like real ContentBlockManager.
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
Thin wrapper only used in tests. Tests now import extract_text_from_content
directly from utils.text.
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
Method always returned 0 and was never called. Queue positions
are computed on-the-fly in _update_queue_positions via get_queue_snapshot.
Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>