Skip to content

feat: add temperature parameter to LLMClient interface#382

Merged
BYK merged 1 commit into
mainfrom
feat/llm-temperature
May 19, 2026
Merged

feat: add temperature parameter to LLMClient interface#382
BYK merged 1 commit into
mainfrom
feat/llm-temperature

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 19, 2026

Summary

Add optional temperature field to LLMClient.prompt() opts and set temperature: 0 in all worker call sites to eliminate eval variance caused by non-deterministic LLM sampling.

Changes

Interface (packages/core/src/types.ts)

  • Added temperature?: number to the LLMClient.prompt() opts with JSDoc documenting adapter behavior

Gateway plumbing (packages/gateway/src/)

  • llm-adapter.ts: Thread temperature through buildAnthropicWorkerRequest(), buildOpenAIWorkerRequest(), and createGatewayLLMClient.prompt()
  • batch-queue.ts:
    • Add temperature to PendingRequest.params type
    • Include temperature in queued batch request params
    • Include temperature in OpenAI batch JSONL body (previously only Anthropic batch forwarded the full params)
    • Fix batch fallback path to forward temperature, maxTokens, and workerID from the queued request (previously silently dropped on fallback)

Worker call sites (all set temperature: 0)

  • packages/core/src/distillation.tsdistillSegment(), metaDistillInner()
  • packages/core/src/curator.tsrunInner(), consolidate()
  • packages/core/src/pattern-echo.ts_detect()
  • packages/core/src/search.tsexpandQuery() (with comment noting diversity trade-off)
  • packages/core/src/import/extract.tsextractKnowledge()
  • packages/gateway/src/pipeline.ts — compaction worker

Impact

Eval PR-2 (implicit preferences) ranged from 3.33 to 4.63 across runs with identical code due to non-deterministic distillation output. Temperature=0 makes scores reproducible and enables meaningful A/B testing of prompt changes.

Verification

  • bun run typecheck — passes all 4 packages
  • bun test — 1608 tests pass, 0 failures

Closes #381

Add optional `temperature` field to `LLMClient.prompt()` opts and set
`temperature: 0` in all worker call sites (distillation, curation,
pattern echo, query expansion, import extraction, compaction) to
eliminate eval variance caused by non-deterministic LLM sampling.

Thread temperature through both Anthropic and OpenAI request builders
in the gateway adapter, through the batch queue params (including the
OpenAI batch JSONL body), and through the batch fallback path.

Also fix batch fallback to forward maxTokens and workerID from the
queued request — previously these were silently dropped on fallback.

Closes #381
@BYK BYK force-pushed the feat/llm-temperature branch from ecb8cc9 to 8418594 Compare May 19, 2026 08:51
@BYK BYK merged commit d1427d6 into main May 19, 2026
10 checks passed
@BYK BYK deleted the feat/llm-temperature branch May 19, 2026 08:53
This was referenced May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add temperature parameter to LLMClient interface

1 participant