Skip to content

fix(roadmap): a model call of an implement step has no output cap and a runaway reply holds the tier for 25 minutes #2869

Description

@dan-petty

What happened

The implement Job devops-cli-runner-20261031-130959-b54a for #2739 stopped at group 1 after 27 minutes:

ModelServerError: HTTP 500, model devops-coder, body: litellm.APIConnectionError: Ollama_chatException - Timeout on reading data from socket

The log of the Ollama pod on condor (ollama-48gib) shows what happened. Two chat requests ended with status 200 after exactly 25 minutes and 22 minutes, at 13:37:35 and 13:38:56 UTC. The other chat requests of the day took under 7 s. 25 minutes is the gateway timeout of 1500 s (timeout: 1500 in k8s/llm/gateway/config.yaml). So the model did not stop: it generated until the gateway gave up. The retry (the #2797 resend) did the same and ended the step.

Nothing in the chain caps the output of a call:

  • build_agent and _run_agent in src/devops_cli/roadmap/implement_step.py set no max_tokens.
  • The route devops-coder in the gateway sets no max_tokens or num_predict.
  • The tier has OLLAMA_NUM_PARALLEL=1, so a runaway call holds the only slot of the tier for 25 minutes, and every other request to the tier (reviews, chat, the next Job) waits behind it.
  • With the context of 262144 (feat(k8s): raise the context length of the condor and hawk Ollama tiers to what their GPUs hold #2822), the room to run away is twice as large as at 128000.

What should happen

  • A call of an implement step has an output cap, a constant sized for the biggest honest reply (a whole-file write_file call), set through the model settings of the agent, so Ollama gets num_predict.
  • A call of an implement step has a per-call timeout far under 1500 s, so a runaway call fails in minutes and the existing resend takes over. State the numbers in the proposal with the measured length of the longest honest call in the recorded Job logs.
  • Decide with evidence whether the route needs a cap too, for other clients of devops-coder (reviews have their own routes). Use a gateway setting if it covers it, and do not copy the cap into code that already has it.
  • The stop reason names the cause when the cap or the timeout ends a call.

Evidence

Acceptance criteria

  • A scripted model that never ends a reply ends the call at the cap, and the step reports the cause.
  • A reply of the longest honest size passes under the cap.
  • The per-call timeout of a step is far under the gateway timeout, and a test shows a stuck call ends by it.
  • The proposal states the measured numbers.
  • uv run devops ci passes.

Proposed design

Problem statement

A model call of an implement step has no output cap and no per-call timeout. A runaway reply generates until the gateway timeout of 1500 s, holding the single parallel slot of the tier for 25 minutes. Every other request to the tier waits behind it. The step needs an output cap sized for the biggest honest reply and a per-call timeout far under the gateway timeout.

Acceptance criteria

Requirement: Output cap ends a runaway reply

A model call of an implement step SHALL end at the output cap when the model does not stop, and the step SHALL report the cause.

Scenario: Runaway model hits the cap

  • WHEN A scripted model generates tokens without ending its reply
  • THEN The call ends at the cap and the step reason names the output cap

Requirement: Honest reply passes under the cap

A reply of the longest honest size (a whole-file write_file call) SHALL pass under the output cap.

Scenario: Largest honest reply fits

  • WHEN A model reply contains a whole-file write_file call of the largest honest size
  • THEN The reply completes without hitting the cap

Requirement: Per-call timeout is under the gateway timeout

The per-call timeout of an implement step SHALL be far under the gateway timeout of 1500 s, and a test SHALL show a stuck call ends by it.

Scenario: Stuck call ends by the timeout

  • WHEN A model call is stuck and does not return
  • THEN The call ends by the per-call timeout, which is under 1500 s

Requirement: Proposal states measured numbers

The proposal SHALL state the measured length of the longest honest call and the chosen cap and timeout values.

Scenario: Numbers are stated

  • WHEN The proposal is read
  • THEN It states the measured longest honest call length, the cap value, and the timeout value

Requirement: CI passes

The command uv run devops ci SHALL pass.

Scenario: CI runs

  • WHEN uv run devops ci is run
  • THEN It exits 0

Existing Tool Considered

No check has run. The project's own configuration field AIImplementTaskOverride.max_tokens and the Ollama client's num_predict pass-through (src/devops_cli/ai/client/ollama.py:311) already cover the need to cap output. The LiteLLM gateway supports per-deployment timeout (k8s/llm/gateway/config.yaml). No external tool is needed. The change sets two constants and wires them through the existing plumbing.

Key questions

  • What is the value of the output cap for an implement step model call?: 32768 tokens, sized for the biggest honest reply (a whole-file write_file call). The value should be verified against the measured length of the longest honest call in the recorded Job logs. (best practice) [sources: src/devops_cli/roadmap/implement_step.py, docs/CONFIGURATION.md]
    • Chosen: 32768 tokens. Covers a whole-file write_file call for a large Python file while bounding a runaway to under a minute of generation.
    • Rejected: 65536 tokens. Twice the needed size. A runaway would still hold the tier for several minutes.
    • Rejected: 16384 tokens. May be too small for a whole-file write of a large file.
  • What is the per-call timeout for an implement step model call?: 300 s (5 minutes), far under the gateway timeout of 1500 s. Normal calls take under 7 s, so 300 s gives ample room for a complex multi-tool-call step while bounding a runaway to minutes. (best practice) [sources: k8s/llm/gateway/config.yaml]
    • Chosen: 300 s. Far under 1500 s. Gives ample room for normal calls (under 7 s) while bounding a runaway to 5 minutes.
    • Rejected: 600 s. Still under 1500 s, but a runaway holds the tier for 10 minutes.
    • Rejected: 1100 s. The devops-background value. Too close to 1500 s for the single-slot tier.
  • Does the gateway route devops-coder need a max_tokens or timeout setting?: The route needs a timeout as a safety net for all clients (the implement step and the devops-reasoning fallback). The max_tokens is set by the client (implement step) in its model settings, not in the gateway. This follows the pattern of devops-background, which sets timeout: 1100 and num_retries: 0. (best practice) [sources: k8s/llm/gateway/config.yaml]
    • Chosen: Set timeout on the route, max_tokens on the client. The timeout is a safety net for all clients. The max_tokens is specific to the implement step. This follows the devops-background pattern.
    • Rejected: Set both on the route. Copies the cap into the gateway, which the issue says to avoid. The client already sets it.
    • Rejected: Set neither on the route. Leaves the devops-reasoning fallback without a timeout safety net.
  • How is the output cap wired through to Ollama's num_predict?: Set max_tokens on the model when creating it for the implement step. The Ollama client already passes num_predict when a reply limit is set. The config field AIImplementTaskOverride.max_tokens already exists. (best practice) [sources: src/devops_cli/ai/client/ollama.py:311, docs/CONFIGURATION.md]
    • Chosen: Set max_tokens on the model settings. The client already passes num_predict. The config field exists. No new plumbing needed.
    • Rejected: Set num_predict in the gateway config. The issue says to set it through the model settings of the agent, not the gateway.
  • What does the stop reason say when the cap or timeout ends a call?: The stop reason names the cause: 'output cap reached' when max_tokens ends the call, or 'call timeout' when the per-call timeout ends it. The existing _stop_reason and _model_call_reason functions format the error. They need to include the specific cause. (best practice) [sources: src/devops_cli/roadmap/implement_step.py]
    • Chosen: Name the cause in the stop reason. The issue requires it. The existing error formatting can be extended to include the cause.
    • Rejected: Leave the stop reason as-is. The issue explicitly requires the stop reason to name the cause.
  • What is the measured length of the longest honest call in the recorded Job logs?: The issue states that normal chat requests took under 7 s and the runaway calls took 25 and 22 minutes. The exact token count of the longest honest call is not stated in the issue body. The value should be measured from the Job logs of devops-cli-runner-20261031-130959-b54a for fix(security): the subprocess environment guard accepts GH_TELEMETRY_ENDPOINT_URL, which sends gh telemetry to a caller URL #2739. [sources: src/devops_cli/roadmap/implement_step.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Oct 31, 2026
  2. dan-petty commented on Oct 31, 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/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. A runaway reply blocks the tier for 25 minutes and fails the step, but it is intermittent and retryable.
    • Value: Medium. Prevents a single runaway reply from blocking the tier and failing the step with an unclear cause.
    • Effort: Medium. Requires setting max_tokens in agent code, adding a per-call timeout, updating gateway config, and writing tests.
    • Related: fix(service): the model lanes of all repositories call the one-slot background tier at the same time, and a call that waits behind them more than 1,100 s fails #2564, which asks for a different change. Both items address a call holding the one-slot Ollama tier, but #2564 fixes concurrent-lane queuing while the candidate adds an output cap and per-call timeout to stop a single runaway reply.
  3. added
    priority/p2-medium
    status/in-progress
    and removed
    status/new
    on Oct 31, 2026
  4. removed
    status/in-progress
    on Oct 31, 2026
  5. added a commit that references this issue on Oct 31, 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/mediumpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions