kubeflow / kubeflow/docs-agent
bug: httpx.AsyncClient created per-request in server-https/app.py
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 42
- Forks
- 111
- Avg merge
- 6d 23m
- Merged PRs (30d)
- 2
Description
Context
server-https/app.py (line 202) creates a new httpx.AsyncClient on every incoming request rather than reusing a shared instance.
Problem
Every request opens a new connection pool and tears it down — redundant TLS handshakes, file descriptor churn, no benefit from HTTP keep-alive. Under any real load this becomes measurable overhead and can exhaust fd limits.
Why This Order
Same file as the CORS fix (#76) and replacing the linear query flow in server-https/app.py. Fix the client lifecycle first so subsequent changes don't build on top of the broken pattern.
Acceptance Criteria
- A single
httpx.AsyncClientis created at app startup via FastAPIlifespan - All route handlers reuse it via
request.app.state - Client is properly closed on shutdown — no ResourceWarning in tests
Related
server-https/app.py:202- Parent tracking issue: #72
- Blocks: Kagent agent layer and replacing the linear query flow in server-https/app.py
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in server-https/app.py at line 202 and trace how the FastAPI application and route handlers access the HTTP client. Move client creation into the app lifespan and make handlers reuse the shared instance through request.app.state. Done means one client is created at startup, closed on shutdown, and tests produce no ResourceWarning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100