Repository navigation
Description
Problem Description
LLMClient.chat and chat_messages (src/devops_cli/ai/client/unified.py) take **kwargs and use none of them. A caller that passes temperature, top_p or seed gets no error, and the request carries the sampling of the client's config instead. The payload builders read self._config.temperature and self._config.top_p (ai/client/openai.py, ai/client/ollama.py), and the cache key reads the same config.
Review group analysis passes temperature, top_p and seed from its SamplingRecord on each call (src/devops_cli/review/analysis.py, _run_model_job), so it believes it sets them. Found while fixing #2447, which makes the record name the analysis task's configured sampling.
Reproduction Steps
- Build an
LLMClientwhose config hastemperature: 0.1. - Call
client.chat("system", "user", temperature=0.9, seed=7)against a fake model at the HTTP edge. - Read the request body.
Expected vs Actual Behavior
- Expected: the request carries
temperature0.9 andseed7, or the call refuses an argument it does not support. - Actual: the request carries
temperature0.1 and no seed, and no error is raised.
Environment Diagnostics
origin/main d156ce7 (2026-10-28).
Existing Tool Considered
The OpenAI-compatible API, Ollama and Anthropic take temperature, top_p and seed (Anthropic: no seed) per request. No new tool is needed: either pass them through to the payload and the cache key, or remove **kwargs so that an unknown argument is a TypeError.
Source: #2447
Proposed design
Problem statement
LLMClient.chat and chat_messages accept **kwargs but silently ignore temperature, top_p, and seed. A caller that passes these values, such as the review analysis module, believes it sets per-call sampling, but the request carries the client's config defaults instead. No error is raised, so the wrong sampling is used and the cache key does not reflect the intended values.
Acceptance criteria
Requirement: Per-call sampling in request payload
When a caller passes temperature, top_p, or seed to chat or chat_messages, the HTTP request body SHALL carry those values.
Scenario: Caller passes temperature=0.9 and seed=7
- WHEN A caller invokes client.chat(system, user, temperature=0.9, seed=7) against a fake model at the HTTP edge
- THEN The request body contains temperature 0.9 and seed 7
Requirement: Per-call sampling in cache key
The cache key generated for a chat call SHALL include the per-call temperature, top_p, and seed values when they are provided.
Scenario: Two calls differ only in temperature
- WHEN A caller invokes chat with temperature=0.1 and then with temperature=0.9 for the same system and user text
- THEN The two calls produce different cache keys
Requirement: Config default fallback
When a caller does not pass a sampling parameter, the request SHALL use the value from the client's config.
Scenario: Caller omits temperature
- WHEN A caller invokes client.chat(system, user) with config temperature set to 0.1
- THEN The request body contains temperature 0.1
Requirement: Unknown keyword argument rejected
A call to chat or chat_messages with a keyword argument that is not a recognized parameter SHALL raise TypeError.
Scenario: Caller passes an unrecognized keyword
- WHEN A caller invokes client.chat(system, user, unknown_param=1)
- THEN A TypeError is raised
Requirement: Seed omitted for unsupported providers
When the provider does not support seed, the request body SHALL omit the seed field even if the caller passes one.
Scenario: Caller passes seed to a Claude provider
- WHEN A caller invokes client.chat(system, user, seed=7) with provider set to claude
- THEN The request body does not contain a seed field
Existing Tool Considered
No new tool or library is needed. The OpenAI-compatible API, Ollama, and Anthropic APIs natively accept temperature, top_p, and seed per request (Anthropic does not accept seed). The fix threads the caller's values through the existing call chain to the HTTP payload and the cache key. The written cost of building this code is the change to two or three files in src/devops_cli/ai/client/ to add explicit parameters and pass them to the payload builders and cache key generation.
Key questions
- **Should the fix pass per-call values through to the payload, or remove kwargs so unknown arguments raise TypeError?: Pass the values through. The review analysis module already passes temperature, top_p, and seed and expects them to reach the model. The OpenAI, Ollama, and Anthropic APIs all accept per-request sampling. Removing **kwargs would break existing callers that legitimately need per-call sampling. (best practice) [sources: src/devops_cli/review/analysis.py, src/devops_cli/ai/client/unified.py]
- Chosen: Pass temperature, top_p, seed through to payload and cache key. Callers already pass these values and expect them to work. The provider APIs support per-request sampling. This is the standard pattern for LLM clients.
- Rejected: Remove **kwargs so unknown arguments raise TypeError. This would break the review analysis module, which legitimately needs per-call sampling. It also removes the ability to set sampling per call, which the provider APIs support.
- Which parameters does the fix cover?: temperature, top_p, and seed. These are the three parameters that the body names and that the review analysis module passes. Anthropic does not accept seed, so seed is omitted for that provider. [sources: src/devops_cli/review/analysis.py, src/devops_cli/ai/client/unified.py]
- Which files hold the code that must change?: src/devops_cli/ai/client/unified.py holds chat, chat_messages, _retry_chat_dispatch, and _dispatch_messages. The payload builders in src/devops_cli/ai/client/openai.py and src/devops_cli/ai/client/ollama.py read self._config.temperature and self._config.top_p. The cache key is generated in chat_messages in unified.py. [sources: src/devops_cli/ai/client/unified.py, src/devops_cli/ai/client/openai.py, src/devops_cli/ai/client/ollama.py]
- How should the per-call value interact with the config value in the payload builder?: The per-call value takes precedence when it is not None. When it is None, the builder falls back to self._config.temperature or self._config.top_p. This preserves the existing behavior for callers that do not pass per-call values. (best practice) [sources: src/devops_cli/ai/client/unified.py]
- Chosen: Per-call value overrides config when not None. This is the standard override pattern. It preserves existing behavior for callers that do not pass per-call values, and gives callers that do pass them the expected result.
- Rejected: Per-call value replaces config entirely. This would require callers to pass all sampling parameters or get no sampling at all. It breaks existing callers that rely on config defaults.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Oct 28, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
Parameters are silently ignored, producing wrong AI output without any error.Callers believe they set per-call sampling but get config defaults silently, which corrupts review-analysis results.Fixes silent parameter drops that mislead callers and produce incorrect model outputs.Either forward three kwargs to the payload builder and cache key, or remove the **kwargs signature; a small change in two or three files.Both address sampling parameters not reaching the model, but 1070 covered num_ctx on the gateway and review-session recording, while this candidate is the specific **kwargs drop in LLMClient.chat and chat_messages.devops-cli-service commentedon Oct 29, 2026
Status set to Ready at 0f7bc26 (see proposed design in issue body).
devops-cli-service commentedon Nov 1, 2026
Staged: branch
fix/2559-llmclient-chat-takes-temperature-top-p, draft pull request #2997. The pull request plans the item and closes no issue.The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:
These paths of the plan are no file on the default branch, and no group creates them:
tests/ai/client/test_unified_sampling.py,tests/ai/client/test_provider_sampling.py,tests/ai/client/test_cache_key_sampling.py. A person checks that the plan names them right.12 remaining items
devops-cli-service commentedon Nov 1, 2026
Stopped at group 1.
Reason:
Last message of the agent: Now let me implement the changes step by step. First, I'll add the
CallSamplingclass to models.py:The job discarded this work. Read it before you retry:
The item is Blocked, and the job will not run it. Fix the cause. Then comment
implement: retry. The Service also clears the stop one time when a new runner image rolls out.devops-cli-service commentedon Nov 1, 2026
The runner Job devops-cli-runner-20261101-171759-d5a6 ended: succeeded.
Image digest: sha256:04d655904252706a7321aed38fa5cafd293625c5db469f252f57163a7c463f16
The last lines of its log:
devops-cli-service commentedon Nov 1, 2026
Cleared the stop at group 1 by the rule
digest: the runner image changed since the stop, from sha256:04d655904252706a7321aed38fa5cafd293625c5db469f252f57163a7c463f16 to sha256:c4ca1742d66bef1bfb15d41d7c54ebf2d0c674a8aaf413f2b28253a0963e4ab0. The item is Planned again, and the Service takes it in the next round. The Service clears a stop one time for each runner image. A new stop on this image waits for a commentimplement: retry.docs(openspec): archive the change of #2559
docs(openspec): archive the change of #2559