fix(plugin): declare llm.maxTokens and llm.headers as first-class config keys - #2248
Open
kiwipaulrob wants to merge 2 commits into
Open
fix(plugin): declare llm.maxTokens and llm.headers as first-class config keys#2248kiwipaulrob wants to merge 2 commits into
kiwipaulrob wants to merge 2 commits into
Conversation
…fig keys llm.maxTokens and llm.headers are read at runtime (client.ts reads config.maxTokens, providers spread config.headers) but were absent from DEFAULT_CONFIG and LlmSchema/SkillEvolverSchema, so every boot logged "unknown config key 'llm.maxTokens'" and "unknown config key 'llm.headers.<key>'" (pruneUnknown recursed into the empty headers slot and warned per user key). Add both to defaults + schema, and teach pruneUnknown that an empty-object default slot is a free-form map that must be kept as-is, eliminating the per-key warnings. Adds a regression test covering acceptance, defaults, range validation and the free-form-map warning suppression.
Collaborator
✅ Automated Test Results: PASSEDAll tests passed (7/7 executed). memos_local_plugin/unit: 7/7. Duration: 3s Branch: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
llm.maxTokensandllm.headersare read at runtime (LLM client resolvesconfig.maxTokenswith a 1024 fallback; every provider spreadsconfig.headersinto requests) but are absent fromDEFAULT_CONFIGand the config schema. Every boot logsunknown config key 'llm.maxTokens', and onceheadersis present,pruneUnknown()recurses into the empty default slot and warns for every user header key (unknown config key 'llm.headers.User-Agent').This PR declares both keys as first-class config, adds defaults, and fixes
pruneUnknown()so empty-object default slots are treated as free-form maps.Change
core/config/defaults.ts— addmaxTokens: 1024+headers: {}to thellmtree; addmaxTokens: 1024toskillEvolverandl3Llm(both shareSkillEvolverSchema).core/config/schema.ts— declaremaxTokens(range 16–131072, default 1024) +headers(Record<string, string>) inLlmSchema; declaremaxTokensinSkillEvolverSchema.core/config/index.ts—pruneUnknown(): an empty-object default slot is a free-form map (Record<string, string>), so keep the whole user object as-is instead of recursing and warning per key.tests/unit/config/llm-max-tokens-headers.test.ts— new regression suite: acceptance without warnings, defaults, range validation, non-string header rejection, unrelated-field preservation.Tests
npx vitest run tests/unit/config tests/unit/llm→ 148 passed (10 files)npx tsc -p tsconfig.json --noEmit→ clean (exit 0)Related
Fixes #2247
Environment
Type of change
How Tested
npx vitest run tests/unit/config tests/unit/llm— 148 passednpx tsc -p tsconfig.json --noEmit— 0 errorsresolveConfig({ llm: { maxTokens: 2048, headers: { "User-Agent": "test" } } })returns both values with zero warnings;resolveConfig({})yieldsmaxTokens: 1024,headers: {}Checklist