Skip to content

Conversation

@DouweM
Copy link
Collaborator

@DouweM DouweM commented Jul 23, 2025

Split out of #2290 because the tests/models/test_huggingface.py::test_hf_model_thinking_part_iter test prints this:

/home/DouweM/pydantic-ai/.venv/lib/python3.12/site-packages/huggingface_hub/inference/_generated/_async_client.py:303: 
UserWarning: Deleting 'AsyncInferenceClient' client but some sessions are still open. This can happen if you've stopped streaming data from the server before the stream was complete. To close the client properly, you must call `await client.close()` or use an async context (e.g. `async with AsyncInferenceClient(): ...`.
  warnings.warn(
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x760e265fcf50>

And CI fails on tests/models/test_mcp_sampling.py::test_assistant_text_history with the same Unclosed client session error.

@DouweM DouweM self-assigned this Jul 23, 2025
@github-actions
Copy link

Docs Preview

commit: ed95a03
Preview URL: https://38c0e8cd-pydantic-ai-previews.pydantic.workers.dev

@DouweM
Copy link
Collaborator Author

DouweM commented Jul 23, 2025

@hanouticelina Can you please have a look here? I think we weren't seeing this issue before in #1911 because all the tests were mocking the stream.

The warning states:

This can happen if you've stopped streaming data from the server before the stream was complete.

But as far as I can see we are streaming the entire request.

@hanouticelina
Copy link
Contributor

Hey @DouweM,
We've just released a patch of huggingface_hub==0.33.5 that should fix this warning: huggingface/huggingface_hub#3252.

Would you mind updating the minimum huggingface-hub version to 0.33.5 in the pyproject.toml and letting me know if the warning still appears?

Thanks!

@DouweM DouweM merged commit f72ad2f into streaming-think-tags Jul 24, 2025
10 checks passed
@DouweM DouweM deleted the streaming-think-tags-hf branch July 24, 2025 13:02
@DouweM
Copy link
Collaborator Author

DouweM commented Jul 24, 2025

@hanouticelina Thanks Célina!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants