Repository navigation
Description
Problem or Motivation
_run_decide in src/devops_cli/ai/jev.py runs asyncio.run(model.decide(request, settings)). Each call starts a new event loop. A SystemOneModel that owns its HTTP client (the model that create_jev_model builds) keeps pooled connections that belong to the loop of the first call. The second call with the same model fails with RuntimeError: Event loop is closed.
I found it in a live run of a new caller (#4298): the first Jev request worked and the next request on the same model raised the error. The model that the gateway settings build gets a client of the HTTP entry point, which the provider does not own, so async with model does not replace it. The caller must build a model for each request and close its client on the loop that used it. select_skill_with_jev makes two requests with one model, so it hits the same fault. The tests of jev.py do not see it, because they build the model with a mock transport and so the provider owns no client.
I reproduced it with a model over a loopback socket (a keep-alive HTTP server in the test process): without the fix the second request raises Event loop is closed.
Proposed Solution & Architectural Design
Build a model for each request and close its client on the loop that used it, as #4298 does in src/devops_cli/roadmap/intake/intake_jev.py. When #4309 gives jev.py a public decide_with_jev, put the context there once and let both callers use it. Add a test that makes two requests with one model that owns its client.
Target Subsystem
AI & Agentic Review Pipeline.
Existing Tool Considered
The pydantic_ai provider refreshes a client that it owns (providers/__init__.py, _refresh_http_client), but not one that the caller gives it. No new tool is needed: httpx2.AsyncClient.aclose() closes the client.
Activity
dan-petty commentedon Nov 10, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(ai)scope of the title gives the scope.A runtime error breaks the second request on the same model, but a workaround exists (build a model per request).Fixes a real failure when a caller makes two Jev requests with one model.The fix is to build a model per request and close its client, a small change already shown in #4298.Both items modify jev.py, but #4309 adds a public decide function while the candidate fixes the RuntimeError from reusing an HTTP client across event loops.dan-petty commentedon Nov 10, 2026
This is a duplicate of #4319, which an agent works on. I added my evidence there.