Skip to content

feat(ai): gpt-oss reasoning effort for group analysis is measured and set on its gateway deployments #479

Closed as not planned

Description

@dan-petty

Refreshed plan (2026-10-17, unblocking review)

This section supersedes any text below that conflicts with it.

Decisions

Scope

Delivery

  1. Person-run, no PR: the close-if-unused check, then three --no-cache branch reviews of one branch for each setting: gpt-oss:20b at low, gpt-oss:20b at medium, and qwen3-coder:30b as the control. Effort is set per run with ai.tasks.analysis.reasoning_effort, which reaches a gpt-oss pin once fix(ai): reasoning request parameters follow the model's declared capability, not its name #888 and refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 have landed.
  2. Closes feat(ai): gpt-oss reasoning effort for group analysis is measured and set on its gateway deployments #479. Feasibility first, recorded in the task file: LiteLLM v1.103.0 passes a deployment-level reasoning_effort to ollama_chat (Ollama's think level) and does not drop it under drop_params: true, and whether a request's own reasoning_effort overrides it. Also recorded: whether the client, after fix(ai): reasoning request parameters follow the model's declared capability, not its name #888 and refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001, sends the gpt-oss:20b pin an effort when neither ai.tasks.analysis.reasoning_effort nor ai.reasoning_effort is set. A task inherits the global value (src/devops_cli/config/settings.py:543-568), and today's reasoning branch falls back to medium (src/devops_cli/ai/client/openai.py:65). If the value does not pass through, or the client always sends the pin an effort that overrides the deployment's so the pin cannot behave as the pool does, stop and comment the evidence on the issue instead of adding code.

Acceptance criteria

  • (person-run) The close-if-unused answer is on the issue before any measurement.
  • (person-run) The issue gets one row per run: report-stage llm_calls, completion_tokens, wall_seconds, finish_reasons and truncated by backend from profile.json; verified and rejected groups and rejections from analysis.json; reasoning share from feat(cli): reasoning-token share in the spend ledger and provider-reported stream usage #591's count, or "unmeasured" if feat(cli): reasoning-token share in the spend ledger and provider-reported stream usage #591 has not landed.
  • Both gpt-oss deployments carry the same chosen reasoning_effort, the qwen3-coder deployments carry none, and an offline test pins the value. The pinned-group test still shows the gpt-oss:20b group copying the pool's gpt-oss deployment, now including reasoning_effort.
  • Any reply cap this item sets lands after fix(review): a group-analysis reply cut at its token cap is rejected, not shown as a checked explanation #876 and is pinned by the same test. In the post-deploy review, fewer than 5% of gpt-oss report-stage replies end with length (the issue's 2026-10-02 threshold), and the verified-group count stays within the range of medium's three runs.
  • Tests run offline: no network, gateway or model.
  • uv run devops ci passes.
  • (person-run) After the config is deployed, one --no-cache review pinned to gpt-oss:20b, with neither ai.tasks.analysis.reasoning_effort nor ai.reasoning_effort set, gives report-stage completion tokens and wall time within the chosen setting's measured range, showing the gateway applies the value.

Current references (at 3dd7fa6)

  • Group-analysis call, with no reply cap and no reasoning parameter: src/devops_cli/review/analysis.py:700-706; run from src/devops_cli/ai/review/pipeline.py:4191-4218 (only with personas until refactor(review): the persona review stage, the legacy segment engine and review-time RAG are deleted, and devops review builds a model client only for the explanation stages #1151 PR 1, :4198), in the report stage at src/devops_cli/ai/review/runner.py:1070-1071; client from ai.for_task("analysis") at runner.py:469.
  • analysis.json: src/devops_cli/review/analysis.py:185-210. profile.json stage fields: src/devops_cli/ai/review/profile.py:88-103, filled at :240-267.
  • gpt-oss gets standard parameters by name today: src/devops_cli/ai/client/models.py:259-268, lists at src/devops_cli/config/constants.py:2132-2148, branch at src/devops_cli/ai/client/openai.py:106-109 (reasoning branch :61-69, which falls back to medium at :65 when no effort is configured).
  • Reply limit: src/devops_cli/ai/client/base.py:137-142; max_tokens unset by default at src/devops_cli/config/settings.py:432 and :466; reasoning_effort per task at :427, global at :461, which a task inherits when its own is unset (for_task, :543-568).
  • gpt-oss deployments: k8s/llm/gateway/configmap.yaml:86-90 (devops-review) and :106-110 (gpt-oss:20b pin); drop_params: true at :156; LiteLLM image pin at k8s/llm/gateway/deployment.yaml:32.
  • Pinned-group test: tests/test_k8s_llm_gateway.py:250-292, whose allowed litellm_params keys are at :288.
  • devops-review is also the gateway tune's default group (src/devops_cli/config/defaults.py:105), so a deployment-level value changes the tune's gpt-oss calls too.

Dependencies and order


Context & Rationale

In the tuner's cost pass, gpt-oss 20B spends its whole 200-token budget, much of it on reasoning, where the Qwen models answer in about 120 tokens. Reasoning effort is not set per deployment. The Ollama nodes may be spending serial time on reasoning a review does not need, or cutting findings short when the budget is too small.

Scope & Deliverables

  • Context & Rationale*: In the tuner's cost pass, gpt-oss 20B spends its whole 200-token budget, much of it on reasoning, where the Qwen models answer in about 120 tokens. Reasoning effort is not set per deployment. The Ollama nodes may be spending serial time on reasoning a review does not need, or cutting findings short when the budget is too small.
  • Deliverable*: Measure findings and verification outcomes against reasoning effort (low, medium) and completion budget for each reasoning deployment. Set reasoning_effort and max_tokens per deployment in the gateway.

Strategic Alignment

Scope added 2026-10-02: branch reviews of release/v0.2.25 show gpt-oss:20b running out of its reply budget, mostly in verification. In sessions 20261002-163203 and 20261002-180320, 39 of 76 verification calls served by gpt-oss ended with finish reason length (17 of 35, 22 of 41). In 20261002-200610 it was 31 of 58. None of 133 qwen3-coder verification calls did. The source is profile.json stages[].truncated and backends; ollama-16gib and ollama-24gib serve gpt-oss (k8s/llm/gateway/configmap.yaml:99-108). The verifier's cap is min(8,192, 2,048 + 384 per finding) (ai/review/verification.py:1959-1965), and reasoning counts against it. devops-review gets no reasoning_effort, because is_reasoning_model decides by name (ai/client/models.py:236-245, used at ai/client/openai.py:101-104). #888 owns that part. A cut verifier reply binds a verdict only if json_repair salvages part of its JSON (core/serialization.py:76-82). Otherwise its findings stay UNVERIFIED with no note (verification.py:2133-2140). It is not cached either (ai/client/unified.py:626), so the next run pays for it again. The release review evaluation counts 40 of 76 and 42 of 92 reported UNVERIFIED findings in files with no complete verifier reply. It also found that verdicts changed 68% of the time when the other model verified. Persona replies were cut 5 times in the same sessions, all on gpt-oss (#876).

  • (person-run) One branch review of at least 50 changed files after the change has fewer than 5% of gpt-oss verification replies ending with length. The figures go on the issue next to the ones above.
  • An offline test pins the chosen reasoning_effort and reply budget for gpt-oss where this item sets them: the gpt-oss deployments in k8s/llm/gateway/configmap.yaml, or the client defaults if the client keeps sending the cap.

Scope added 2026-10-03 from review sessions 20261003-005122 (S7, at b6847e9) and 20261003-012555 (S8, at 0ce4736) (.data/review-evaluation-20261003-s7-s8.md, sections 3, 6 and 7). Lines are at da50329. gpt-oss:20b still runs out of its verifier budget, and qwen3-coder:30b never does. In S7 and S8, 9 of the 20 verifier calls gpt-oss served ended with finish reason length (5 of 8, then 4 of 12). qwen3-coder: 0 of 33. Across S2 to S8 it is 86 of 169 against 0 of 183. The grooming note of 2026-10-02 lowered this item to p3 because no defect had been measured. S2 to S8 now measure one.

All 9 cuts were on ollama-16gib-fast, and each stopped at exactly its cap: 2,048 + 384 per finding, at most 8,192, reasoning included (_verification_reply_cap, src/devops_cli/ai/review/verification.py:2109-2115; src/devops_cli/config/defaults.py:399-401). The ledger rows are the cases:

Session Ledger row File Findings Cap, all used Prompt tokens
S7 9991 k8s/monitoring/service-aliases.yaml 4 3,584 6,651
S7 9992 src/devops_cli/ai/mcp/server.py 2 2,816 42,240
S7 10006 src/devops_cli/commands/ci.py 1 2,432 21,336
S7 10007 src/devops_cli/config/settings.py 2 2,816 21,922
S7 10008 tests/test_all_commands_help_dryrun.py 1 2,432 10,351
S8 10048 src/devops_cli/commands/ci.py 1 2,432 21,337
S8 10051, 10055 src/devops_cli/ai/rag/indexer.py and tests/test_rag_multi_project_indexer.py (the ledger does not say which is which) 1 each 2,432 16,866 and 11,622
S8 10064 src/devops_cli/ai/spend/pricing.py 4 3,584 16,751

The ledger has no file column. Rows are matched to the cut findings by finding count (the cap), and otherwise by prompt size. server.py's call is the largest verifier call in each session. ci.py is the only single-finding cut in both runs, and only 10006 and 10048 match across them (21,336 and 21,337 tokens).

  • The 9 calls used 169,076 prompt and 24,960 completion tokens, and 1,189 s of call time (summed over parallel calls), for no verdict.
  • They left 17 findings UNVERIFIED (10 and 7). Row 10064 was the call for S8's only 2 valid findings (pricing.py:55 and :65, lenient label).
  • 9 of the 16 S7-to-S8 status changes involve a gpt-oss cut on one side.
  • 5 of the 9 cuts were single-finding calls at the 2,432 floor. The 11 complete gpt-oss verifier replies in S7 and S8 are cached with their reasoning. Reasoning is 63% to 87% of each reply's characters (median 82%, characters, not tokens). Complete gpt-oss replies take a median of 1,415 completion tokens on 16gib-fast, against 338 for qwen3-coder. So the budget goes to reasoning, not to the answer [inference].

Changed since the 2026-10-02 scope: a cut reply no longer binds any verdict. Since #846 the cut branch returns before parsing and notes each finding verifier-reply-cut (verification.py:2293-2297), 17 of 17 in S7 and S8. The sentence above about a salvaged verdict and "UNVERIFIED with no note" no longer holds.

  • (person-run) The before-and-after table starts from the 9 cut calls above. After the change, a branch review with --no-cache that verifies the same 8 files gives, for each verifier call gpt-oss serves, the finish reason, the completion tokens and the reasoning share. A cut reply is not cached (src/devops_cli/ai/client/unified.py:626), so its reasoning share comes from feat(cli): reasoning-token share in the spend ledger and provider-reported stream usage #591's reasoning-token count once that lands, or is listed as unmeasured. A file the gateway routes to qwen3-coder is listed as not exercised.
  • (person-run) In that review, no gpt-oss verifier call over one finding ends with length.
  • (person-run) The table also gives VERIFIED and INVALIDATED counts per model, so a budget change is not judged by the cut rate alone.

Key question added: Should verification be pinned to qwen3-coder instead, since it never cut? (proposed) No, not as a precision fix [judgment, from the evaluation]. qwen3-coder gave 15 of the 19 VERIFIED verdicts in S7 and S8, and none is strictly valid: 13 are false and 2 are the overrated pricing excepts. 2 of S8's top 8 report rows are qwen3-coder confirmations whose own reason refutes the claim: workspace.py:43 (cache llm_6818ef36…, row 10050) and main.py:84 (llm_f3d7fc26…, row 10067). Since #948 ranks VERIFIED first, a false confirmation costs more than a cut, which leaves the finding UNVERIFIED with a note. With the gateway config of S7 and S8, a pin would also send verification to 48gib-slow, which took 160.8 s for 12,994 prompt tokens (row 10065). False confirmations need the evaluation's sketch A, added to #845 on 2026-10-03 (a confirmation whose reason refutes the claim is not applied), and #770 (a syntax claim judged by parsing). This item stays the fix for the cuts. #962's per-model baseline is closed, and a pin is a routing decision, not an issue.

Activity

  1. added this to the v0.2.23 milestone on Sep 24, 2026
  2. added
    type/feature
    scope/ai
    priority/p2-medium
    on Sep 24, 2026
  3. modified the milestones: v0.2.23, v0.2.24 on Sep 28, 2026
  4. added a commit that references this issue on Sep 28, 2026
  5. modified the milestones: v0.2.24, v0.2.23 on Sep 30, 2026
  6. removed this from the v0.2.23 milestone on Oct 1, 2026
  7. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    Moved from the shipped v0.2.23 to the backlog. It is still valid (checked 2026-10-01), and P2 items don't displace P1 work in the planned releases.

  8. added
    priority/p3-low
    scope/review
    and removed
    priority/p2-medium
    on Oct 2, 2026
  9. dan-petty commented on Oct 2, 2026

    @dan-petty
    OwnerAuthor

    Grooming (2026-10-02): Priority p2-medium → p3-low. Speculative tuning ('may be spending… or cutting short'). No defect has been measured in real reviews.

    Checked against the code at the release/v0.2.25 tip.

  10. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    What S10 adds (review session 20261003-034353, release/v0.2.25 at d6ebe97; .data/review-evaluation-20261003-s10.md, section 3). These are cuts measured in a real review, which the 2026-10-02 grooming note said were missing.

    gpt-oss:20b (16gib-fast) was cut on 2 of its 3 fresh verifier calls, each at exactly the per-finding cap. The cap is min(8192, 2048 + 384 × n) (_verification_reply_cap, verification.py:2109; constants at defaults.py:399-401).

    • Ledger row 10531 stopped at 2,432 tokens. It covered 1 finding, test_security_bandit.py:107, which was also cut in S9.
    • Row 10534 stopped at 2,816, with 2 runner findings.
    • Its third call (row 10532, 16 findings) finished at 3,835 of 8,192.

    qwen3-coder was cut on 0 of its 6 calls. Over the evaluated sessions the tally is about 91 of 177 gpt-oss verifier calls cut, against 0 of 197 for qwen [estimate].

  11. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Frozen by the evidence-first review redesign (#1137, owner direction of 2026-10-03): patches to the model generator and verifier stop, and tool-layer fixes continue. The review pool's reasoning budget goes with #1151. Before this item closes, its per-deployment reasoning_effort and max_tokens in the gateway move to #888 (reasoning parameters follow declared capability) and #1070 (sampling settings), because chat and analysis keep them. It stays open, labelled status/blocked, until then.

  12. added
    status/blocked
    on Oct 3, 2026
  13. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #590 and #591 (frozen item, link only). Reasoning text is split by hand-written tag state machines and never counted; #591 keeps estimated rows out of this item's comparison. Found by the 2026-10-08 backlog review.

  14. changed the title [-]feat(ai): reasoning budget tuning for the review pool[/-] [+]feat(ai): gpt-oss reasoning effort for group analysis is measured and set on its gateway deployments[/+] on Oct 18, 2026
  15. removed
    status/blocked
    on Oct 18, 2026
  16. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    The feasibility check fails against the codebase.

    The client always sends reasoning effort to the pinned model. In src/devops_cli/ai/client/openai.py:86, the code falls back to medium when reasoning effort is unset. The gateway deployment gpt-oss:20b declares supports_reasoning: true. Therefore, the client adds payload["reasoning_effort"] = "medium" to each request.

    This request parameter overrides the deployment configuration in the gateway. The mixed group devops-review sends no reasoning parameter because qwen3-coder does not reason. Thus, the pin cannot behave as the pool behaves.

    In addition, the issue lacks the required person-run input. The owner has not recorded whether reviews route group analysis to a gpt-oss deployment. The runtime configuration still sets ai.tasks.analysis.model to qwen3-coder:30b. The issue also has no measurement figures to select an effort.

    Per the delivery instructions and Rule 2, this item returns to New.

  17. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    Closed as not planned under the close-if-unused condition of decision D17 in this issue's refreshed plan.

    The owner asked on 2026-10-24: "fix #479 or close as invalid".

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

    priority/p3-lowscope/aiscope/reviewtype/feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions