Repository navigation
Description
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_agentand_run_agentinsrc/devops_cli/roadmap/implement_step.pyset nomax_tokens.- The route
devops-coderin the gateway sets nomax_tokensornum_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_filecall), set through the model settings of the agent, so Ollama getsnum_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
- Pod log
ollama-48gib-gb2m4,[GIN]lines200 | 25m0s | POST /api/chatat 13:37:35 and200 | 22m0sat 13:38:56 on 2026-10-31. - The stop comment on fix(security): the subprocess environment guard accepts GH_TELEMETRY_ENDPOINT_URL, which sends gh telemetry to a caller URL #2739 at 13:37 UTC.
git grep -n max_tokens src/devops_cli/roadmap/implement_step.pyfinds nothing.
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 cipasses.
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 ciis 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
dan-petty commentedon Oct 31, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(roadmap)scope of the title gives the scope.A runaway reply blocks the tier for 25 minutes and fails the step, but it is intermittent and retryable.Prevents a single runaway reply from blocking the tier and failing the step with an unclear cause.Requires setting max_tokens in agent code, adding a per-call timeout, updating gateway config, and writing tests.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.chore(main): release 0.28.0 (#2880)