Skip to content

fix(ai): ask-jev refuses no context and reports unsure #5284

Done

Description

@dan-petty

Problem or Motivation

devops ai ask-jev and the MCP tool ai_ask_jev (src/devops_cli/ai/jev_ask.py) break five documented rules.

  1. No context. With no --context, the code sends the question text as the state and also as the instructions (state = context if context.strip() else question, jev_ask.py:151). So Jev judges the question with no evidence and answers from its weights.
  2. A coin flip reads as yes. The command prints yes when p >= 0.50 (CONST_AI_JEV_DEFAULT_BOOLEAN_THRESHOLD, jev_ask.py:208), else no. The skill tells agents that a value near 0.5 means that Jev does not know, but the answer field does not say it.
  3. Characters, not bytes. CONST_AI_JEV_ASK_MAX_INPUT_CHARS caps the input at 16,000 characters. With no --context, the question goes two times. Multibyte text can also go above 32,000 bytes.
  4. No timeout. The command sets no timeout, so the 3600 s default of the project HTTP client applies (DEFAULT_HTTP_TIMEOUT_SECONDS). A call that hangs can stop an agent for one hour. The decision step and intake set 30 s. The gateway measured p95 0.40 s in about 3,373 Jev calls.
  5. One question for each call. The command sends one question, named answer.

Proposed Solution & Architectural Design

  1. Refuse a call with no --context. Give a usage error that names the option, and make no request. Keep the plain-string state for one piece of text ("A string is suitable when the use case is simple and requires only one piece of text.", https://docs.typesafe.ai/concepts/state.md).
  2. Print unsure for a noul answer from 0.3 to 0.7. Put the two edges in constants. Stop the use of CONST_AI_JEV_DEFAULT_BOOLEAN_THRESHOLD here (refactor(ai): remove the Jev helpers that nothing calls #5276 deletes the inert bars). The output keeps the probability.
  3. Count bytes. Count the UTF-8 bytes of the state and the questions against a budget of about 32,000 bytes. Refuse a larger request before the call, with a message that gives the count. Share the budget constant with fix(ai): set the Jev context window from the model data #5209.
  4. Set a short timeout, about 10 s, in the model settings of the call. A timeout gives a clear error and a non-zero exit code.
  5. Accept several questions about one context. Let noul take more than one question in one call. Send them in one request, and print one answer for each question in the given order. choice and score keep one question for each call, because their options belong to one question.
  6. Update .agents/skills/ask-jev/SKILL.md and the help text for the new behavior.

Files: src/devops_cli/ai/jev_ask.py, src/devops_cli/ai/jev_ask_models.py, src/devops_cli/commands/ai.py, src/devops_cli/config/constants.py, src/devops_cli/lang/en/help.py, src/devops_cli/lang/en/messages.py, .agents/skills/ask-jev/SKILL.md, tests/ai/.

Target Subsystem

AI & Agentic Review Pipeline (src/devops_cli/ai/jev_ask.py, the command devops ai ask-jev and the MCP tool ai_ask_jev).

Existing Tool Considered

pydantic-ai SystemOneModel with ModelSettings(timeout=...), and several questions in one DecisionRequest (pinned 2.59.0). If #5282 merges first, the command uses the Agent path. No new tool. Cost: about 0.3M tokens and 2 hours.

Acceptance Criteria

  • A test: devops ai ask-jev noul "<question>" with no --context exits with the usage-error code and makes no request.
  • A test with the JevFake transport: p = 0.55 prints unsure, p = 0.75 prints yes, p = 0.25 prints no. Each output holds the probability.
  • A test: a context under 16,000 characters but over the byte budget (multibyte text) is refused before a request.
  • A test: the model settings of the call hold the timeout constant (about 10 s).
  • A test: two noul questions about one context go in one request and print two answers in order.

Related

Source: https://pydantic.dev/docs/ai/models/decision/

Alternatives check of 2026-11-28: in-use.
The repository already uses this tool.
Tool: pydantic/pydantic-ai (https://github.com/pydantic/pydantic-ai), MIT, last activity 2026-11-28, maintained.
Reason: The pydantic-ai docs and facts confirm SystemOneModel forwards a ModelSettings timeout and sends several questions in one request, but refusing a no-context call, the unsure band and UTF-8 byte counting stay project code.

Covers:

  • Forwards timeout in ModelSettings to the request
  • Sends several questions in one DecisionRequest
  • SystemOneModel is the decision-model class the project already uses

Lacks:

  • No refusal of a call with no context
  • No three-way unsure band for probabilities
  • No UTF-8 byte budget for state and questions

Proposed design

Problem statement

Refuse a call with no context. Print unsure in the 0.3-0.7 band. Count UTF-8 bytes. Set a 10 s timeout. Let noul send several questions in one request. The current command sends the question as the state, rounds a coin flip to yes, caps characters, has no short timeout, and sends one question per request.

Acceptance criteria

Requirement: Refuse a call with no context

The ask-jev command and the ai_ask_jev tool SHALL refuse a call with no context before any request.

Scenario: A missing context is refused

  • WHEN The test runs devops ai ask-jev noul "Does this change touch only documents?" with no --context.
  • THEN The command exits with code 2 and the JevFake transport records no request.

Requirement: Print unsure in the middle band

A noul answer SHALL print unsure when its probability of yes is from 0.30 to 0.70 inclusive.

Scenario: A probability in the band prints unsure

  • WHEN The test uses the JevFake transport to return p = 0.55, p = 0.75 and p = 0.25 for three noul calls.
  • THEN The outputs are unsure, yes and no in that order, and each output holds its probability.

Requirement: Refuse a request over the UTF-8 byte budget

The ask-jev command and the ai_ask_jev tool SHALL refuse a request whose state and questions exceed 32,000 UTF-8 bytes before any request.

Scenario: Multibyte context over the byte budget is refused

  • WHEN The test passes a context of fewer than 16,000 characters that holds multibyte text and is larger than 32,000 UTF-8 bytes.
  • THEN The command exits with a validation error that gives the byte count, and the JevFake transport records no request.

Requirement: Set a short timeout

The ask-jev model settings SHALL set a 10 s timeout for each Jev call.

Scenario: The model settings hold the timeout

  • WHEN The test builds the Jev model with the ask-jev settings.
  • THEN The model settings hold a timeout of 10 s.

Requirement: Ask several noul questions in one request

The ask-jev command and the ai_ask_jev tool SHALL send more than one noul question about one context in one request and return one answer for each question in the given order.

Scenario: Two noul questions share one request

  • WHEN The test calls devops ai ask-jev noul "Q1" "Q2" --context "<text>" with the JevFake transport.
  • THEN The transport records one request with two questions, and the output holds two answers in the order Q1, Q2.

Requirement: Keep choice and score to one question

The choice and score kinds SHALL refuse more than one question in a call.

Scenario: Choice refuses a second question

  • WHEN The test calls devops ai ask-jev choice "Q1" "Q2" --option a=A --option b=B --context "<text>".
  • THEN The command exits with a usage error and the JevFake transport records no request.

Requirement: Show the new behavior in help

The ask-jev help text SHALL state that --context is required and that noul accepts several questions.

Scenario: Help shows the required context

  • WHEN The test invokes devops ai ask-jev --help.
  • THEN The help names --context as required and describes several noul questions.

Existing Tool Considered

pydantic-ai (https://pypi.org/project/pydantic-ai) is MIT and maintained. The alternatives check is in-use. The repository already uses it. It forwards timeout in ModelSettings and sends several questions in one request through one output type. It does not refuse a no-context call, give an unsure band or count UTF-8 bytes. Those parts stay project code. No new tool is needed. The written cost of the project logic is about 0.3M tokens and 2 hours.

Key questions

  • Should a call with no context be refused or should the question become the state?: Refuse the call with a usage error before any request. The state must hold evidence. A question is not evidence. Keep the plain-string state for one piece of context. (best practice) [sources: src/devops_cli/ai/jev_ask.py]
    • Chosen: Refuse no context. The model then judges evidence, not its weights, and the command follows the documented rule.
    • Rejected: Use the question as the state. This is the current defect; Jev answers from its weights with no evidence.
  • Which probability band prints unsure?: Print unsure for p from 0.30 to 0.70 inclusive. Print yes above 0.70 and no below 0.30. Put the two edges in constants. (best practice) [sources: src/devops_cli/ai/jev_ask.py]
    • Chosen: Three-way band 0.30/0.70. The confidence guide says above 0.7 reads as yes and below 0.3 as no, and the band needs its own outcome.
    • Rejected: Keep the 0.50 threshold. A coin flip then reads as yes and hides that Jev does not know.
  • What budget and unit should the input check use?: Count UTF-8 bytes of the state and all questions against 32,000 bytes. Refuse a larger request before the call and give the byte count. Use one shared constant for fix(ai): set the Jev context window from the model data #5209. (best practice) [sources: src/devops_cli/ai/jev_ask.py, src/devops_cli/config/constants.py]
    • Chosen: UTF-8 byte budget of 32,000. The Jev FAQ puts about 32,000 bytes at the long-context threshold, and multibyte text can exceed it under a character cap.
    • Rejected: Keep 16,000 characters. The cap misses the byte size and the question can go twice when no context is set.
  • What timeout should the ask-jev call use?: Set 10 s in the pydantic-ai ModelSettings of the call. A timeout gives a clear error and a non-zero exit code. (best practice) [sources: src/devops_cli/ai/jev_ask.py, src/devops_cli/config/defaults.py]
    • Chosen: 10 s in ModelSettings. The gateway p95 is 0.40 s, and 10 s bounds an agent wait without the 3600 s default.
    • Rejected: Keep the 3600 s default. One hung call can stop an agent for one hour.
  • How should several noul questions be named and returned in one request?: Use answer for one question and answer_1 to answer_n for several. Return one JevAnswer for each key in input order. Keep choice and score to one question. (best practice) [sources: src/devops_cli/ai/jev_ask.py]
    • Chosen: Numbered answer keys in one DecisionRequest. One request holds the questions, the keys stay stable, and the input order gives the output order.
    • Rejected: One request for each question. The Jev tutorial says to put independent questions in one request, and agents overuse one question per request.
    • Rejected: Use the question text as the key. Duplicate text collides and a long key copies the question into the request keys.
  • How should the CLI and MCP output represent several answers?: Print one answer block for each question in input order. For --json, return the existing single object for one question. Return a list of JevAnswer objects in input order for several questions. (best practice) [sources: src/devops_cli/ai/jev_ask_models.py, src/devops_cli/commands/ai.py]
    • Chosen: Single object for one, list for several. This keeps the current single-question output and gives a clear ordered result for several.
    • Rejected: Always return an envelope with an answers list. This breaks the current single-question JSON and MCP output.
    • Rejected: Write one JSON object per line. This is not one JSON document and is harder for an MCP client.
  • Does this issue depend on fix(ai): set the Jev context window from the model data #5209 or refactor(ai): remove the Jev helpers that nothing calls #5276?: No. Define the shared byte budget constant here if fix(ai): set the Jev context window from the model data #5209 has not added it. Stop using CONST_AI_JEV_DEFAULT_BOOLEAN_THRESHOLD here so refactor(ai): remove the Jev helpers that nothing calls #5276 can delete it. Both changes stay in this pull request. (best practice) [sources: src/devops_cli/config/constants.py, src/devops_cli/ai/jev_ask.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 12, 2026
  4. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found pydantic-ai, the decision-model client the issue already pins and uses (SystemOneModel). It already provides two of the five pieces the issue wants — a forwarded timeout in ModelSettings and several questions sent in one request via one output type — but it does not refuse a context-less call, give an unsure band, or count UTF-8 bytes, which stay project logic, so it covers only part.

    The repository already uses this tool.

    Tool: pydantic-ai (https://pypi.org/project/pydantic-ai)

    • License: MIT
    • Last activity: 2026-11-12
    • Maintained: yes

    Covers:

    • ModelSettings forwards timeout (and temperature, extra_headers, extra_body) to the /v1/systemone request, so the short timeout can be set in the model settings of the call
    • An output type with several fields sends several questions about one state in a single request and answers them together, which serves the multiple-noul-questions-in-one-call rule
    • Decision answers carry a probability and configurable thresholds (decision_boolean_threshold), the basis for an unsure band

    Lacks:

    • No built-in refusal when no context/state is given; the command must raise the usage error and make no request itself
    • No unsure outcome: thresholds round a probability to yes/no, so the 0.3-0.7 band must be added in project code
    • No UTF-8 byte-budget check of the state and questions before the call
    • The command/MCP wiring, output formatting and skill/help text remain project code

    Tools considered:

    Searches run:

    • pydantic-ai ModelSettings timeout SystemOneModel, results: 5
    • pydantic-ai SystemOneModel DecisionRequest, results: 5
    • pydantic-ai github repository, results: 5
    • SystemOneModel DecisionRequest pydantic-ai questions in one request, results: 5
    • pydantic-ai PyPI package agent framework, results: 5

    Sources:

    Checked on 2026-11-16. A person decides what this means for the item. The check changes no label and closes no issue.

  5. added
    status/ready
    and removed
    status/new
    on Nov 17, 2026
  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

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

  7. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: in-use, tool https://pypi.org/project/pydantic-ai. A person decides what the new result means for the item.

    Searches (5)

    Tools considered:

    Searches run:

    • pydantic-ai SystemOneModel ModelSettings timeout DecisionRequest multiple questions, results: 5
    • pydantic-ai ModelSettings timeout request, results: 5
    • pydantic-ai SystemOneModel documentation, results: 5
    • pydantic.dev docs ai models system-one model settings timeout, results: 5
    • pydantic-ai SystemOneModel ModelSettings timeout DecisionRequest, results: 5

    Sources:

  8. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 29, 2026
  10. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:17 UTC

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/mediumpriority/p2-mediumscope/aisource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions