Skip to content

refactor(ai): jev.py exposes a public one-request decide function #4309

Closed

Description

@dan-petty

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_jev with a fake DecisionModel that has settings and with a DecisionRequest
  • THEN the function calls decide of 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_model and calls decide_with_jev with settings and no model
  • THEN create_jev_model is 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_jev in devops_cli.ai.jev and calls route_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 decide call of the model raise ModelAPIError
  • THEN ask_jev raises ModelGatewayUnreachableError and 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_decide exist outside jev.py?: None. The only callers are the helpers inside src/devops_cli/ai/jev.py. The only test that uses it is tests/ai/test_jev_gateway_route.py. [sources: src/devops_cli/ai/jev.py, tests/ai/test_jev_gateway_route.py]
  • Does _run_decide stay as a wrapper, or does decide_with_jev replace it?: Move the body of _run_decide into decide_with_jev and delete _run_decide. The helpers call decide_with_jev with model=decision_model. Update tests/ai/test_jev_gateway_route.py to the public name. The model_settings parameter of _run_decide has no caller in jev.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_decide with decide_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_decide as a thin wrapper. It keeps a second name for the same call and adds no value.
  • Does jev_ask.py let decide_with_jev build the model, or does it pass its own model?: ask_jev builds the model with create_jev_model and passes it as model=. The error handler needs model.base_url for ModelGatewayUnreachableError. A new model for each request also stays true, because the HTTP client of a model belongs to the event loop of its first asyncio.run. (best practice) [sources: src/devops_cli/ai/jev_ask.py, src/devops_cli/ai/jev.py]
    • Chosen: Pass the model that ask_jev builds. The error handler keeps the base URL, and no behavior changes.
    • Rejected: Let decide_with_jev build the model. ask_jev would lose the base URL for its error message.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/refactor
    scope/ai
    status/new
    value/medium
    effort/low
    on Nov 10, 2026
  2. dan-petty commented on Nov 10, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/refactor. The refactor prefix of the title gives the type.
    • Scope: scope/ai. The (ai) scope of the title gives the scope.
    • Priority: P2-Medium. It unblocks clean implementation of #4306 but does not fix a defect or add a user-facing feature.
    • Value: Medium. It removes a private import and gives callers a stable public API, which improves maintainability.
    • Effort: Low. It adds one public wrapper function and updates a few internal call sites in two files.
    • Related: feat(ai): ask-jev command, MCP tool and skill #4306, which asks for a different change. Both work on jev.py and the ask-jev flow, but the candidate refactors the internal API while #4306 adds the ask-jev command.
  3. added
    priority/p2-medium
    on Nov 10, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 10, 2026
  5. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 4f377e1 (see proposed design in issue body).

  6. dan-petty commented on Nov 10, 2026

    @dan-petty
    OwnerAuthor

    Delivered by PR #4331 (closes #4319): jev.py now has the public function decide_with_jev(request, *, model=None, settings=None, model_settings=None), and _run_decide is removed. The ask-jev command and the completeness eval call it. The PR body could carry only one Closes line, so this issue stayed open. Closed as completed.

  7. removed
    status/ready
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/aisource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions