Repository navigation
Description
Problem or Motivation
src/devops_cli/ai/jev.py runs a request through the private function _run_decide. A caller that builds its own DecisionRequest (for example devops ai ask-jev, #4306) has no public function to call. It repeats the three lines of _run_decide, or it imports a private name.
Proposed Solution & Architectural Design
Add a public decide_with_jev(request, *, model=None, settings=None) to jev.py. It returns the DecisionResponse. _run_decide and the helpers of jev.py call it. Then src/devops_cli/ai/jev_ask.py calls it and drops its own call of model.decide.
Target Subsystem
AI & Agentic Review Pipeline.
Existing Tool Considered
The pydantic_ai DecisionModel.decide is the open tool. The change only gives a public name to the call that jev.py already makes.
Proposed design
Problem statement
The module src/devops_cli/ai/jev.py runs a decision request through the private function _run_decide. A caller that builds its own DecisionRequest has no public function to call. jev_ask.py repeats the call of model.decide, with the same merge of settings and the same asyncio.run. The change adds the public function decide_with_jev and makes all callers in src/devops_cli/ai/ use it.
Acceptance criteria
Requirement: Public one-request decide function
The module devops_cli.ai.jev SHALL export decide_with_jev(request, *, model=None, settings=None), which returns the DecisionResponse of one request.
Scenario: Request with a given model
- WHEN a test calls
decide_with_jevwith a fakeDecisionModelthat has settings and with aDecisionRequest - THEN the function calls
decideof the fake once with the request and the settings of the model, and returns the response of the fake
Requirement: Default model
The function decide_with_jev MUST build the model with create_jev_model(settings=settings) when the caller gives no model.
Scenario: No model given
- WHEN a test patches
create_jev_modeland callsdecide_with_jevwithsettingsand no model - THEN
create_jev_modelis called once with those settings and its model answers the request
Requirement: Helpers use the public function
The helpers route_with_jev, select_skill_with_jev, gate_tool_call_with_jev, judge_with_jev and filter_rag_passages_with_jev SHALL call decide_with_jev and SHALL NOT call _run_decide.
Scenario: Routing through the public function
- WHEN a test patches
decide_with_jevindevops_cli.ai.jevand callsroute_with_jev - THEN the patched function receives the request and the helper returns a decision built from its response
Requirement: Ask command uses the public function
The function ask_jev in jev_ask.py SHALL send its request with decide_with_jev and MUST keep its mapping of errors.
Scenario: Gateway error
- WHEN a test makes the
decidecall of the model raiseModelAPIError - THEN
ask_jevraisesModelGatewayUnreachableErrorand the error holds no input text
Requirement: Public export
The list __all__ of devops_cli.ai.jev SHALL name decide_with_jev.
Scenario: Name in the export list
- WHEN a test reads
devops_cli.ai.jev.__all__ - THEN the list contains
decide_with_jev
Existing Tool Considered
The open tool is pydantic_ai, whose DecisionModel.decide already sends the request. It is async only, and it has no sync call that merges the settings of the model. The change adds one small function that wraps it. It adds no new dependency. The cost is low: about one small change of code and tests in one session, and no later upkeep beyond the wrapper.
Key questions
- Which callers of
_run_decideexist outsidejev.py?: None. The only callers are the helpers insidesrc/devops_cli/ai/jev.py. The only test that uses it istests/ai/test_jev_gateway_route.py. [sources: src/devops_cli/ai/jev.py, tests/ai/test_jev_gateway_route.py] - Does
_run_decidestay as a wrapper, or doesdecide_with_jevreplace it?: Move the body of_run_decideintodecide_with_jevand delete_run_decide. The helpers calldecide_with_jevwithmodel=decision_model. Updatetests/ai/test_jev_gateway_route.pyto the public name. Themodel_settingsparameter of_run_decidehas no caller injev.py, so the public function does not take it. (best practice) [sources: src/devops_cli/ai/jev.py, tests/ai/test_jev_gateway_route.py]- Chosen: Replace
_run_decidewithdecide_with_jev. It leaves one function for one job. The project is pre-1.0 and keeps no dead private names (ADR 0005 deletes instead of keeping flags). - Rejected: Keep
_run_decideas a thin wrapper. It keeps a second name for the same call and adds no value.
- Chosen: Replace
- Does
jev_ask.pyletdecide_with_jevbuild the model, or does it pass its own model?:ask_jevbuilds the model withcreate_jev_modeland passes it asmodel=. The error handler needsmodel.base_urlforModelGatewayUnreachableError. A new model for each request also stays true, because the HTTP client of a model belongs to the event loop of its firstasyncio.run. (best practice) [sources: src/devops_cli/ai/jev_ask.py, src/devops_cli/ai/jev.py]- Chosen: Pass the model that
ask_jevbuilds. The error handler keeps the base URL, and no behavior changes. - Rejected: Let
decide_with_jevbuild the model.ask_jevwould lose the base URL for its error message.
- Chosen: Pass the model that
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
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.
refactorprefix of the title gives the type.(ai)scope of the title gives the scope.It unblocks clean implementation of #4306 but does not fix a defect or add a user-facing feature.It removes a private import and gives callers a stable public API, which improves maintainability.It adds one public wrapper function and updates a few internal call sites in two files.Both work on jev.py and the ask-jev flow, but the candidate refactors the internal API while #4306 adds the ask-jev command.devops-cli-service commentedon Nov 10, 2026
Status set to Ready at 4f377e1 (see proposed design in issue body).
fix(ai): a second Jev request on one model works (#4331)
dan-petty commentedon Nov 10, 2026
Delivered by PR #4331 (closes #4319):
jev.pynow has the public functiondecide_with_jev(request, *, model=None, settings=None, model_settings=None), and_run_decideis removed. The ask-jev command and the completeness eval call it. The PR body could carry only oneClosesline, so this issue stayed open. Closed as completed.