Skip to content

fix(plugin): declare llm.maxTokens and llm.headers as first-class config keys - #2248

Open
kiwipaulrob wants to merge 2 commits into
MemTensor:mainfrom
kiwipaulrob:fix/config-llm-maxtokens-headers
Open

fix(plugin): declare llm.maxTokens and llm.headers as first-class config keys#2248
kiwipaulrob wants to merge 2 commits into
MemTensor:mainfrom
kiwipaulrob:fix/config-llm-maxtokens-headers

Conversation

@kiwipaulrob

Copy link
Copy Markdown

Summary

llm.maxTokens and llm.headers are read at runtime (LLM client resolves config.maxTokens with a 1024 fallback; every provider spreads config.headers into requests) but are absent from DEFAULT_CONFIG and the config schema. Every boot logs unknown config key 'llm.maxTokens', and once headers is 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 — add maxTokens: 1024 + headers: {} to the llm tree; add maxTokens: 1024 to skillEvolver and l3Llm (both share SkillEvolverSchema).
  • core/config/schema.ts — declare maxTokens (range 16–131072, default 1024) + headers (Record<string, string>) in LlmSchema; declare maxTokens in SkillEvolverSchema.
  • core/config/index.tspruneUnknown(): 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/llm148 passed (10 files)
  • npx tsc -p tsconfig.json --noEmit → clean (exit 0)
  • New file: 7 tests (acceptance / default maxTokens / default headers / skillEvolver maxTokens / range rejection / header type rejection / unrelated fields)

Related

Fixes #2247

Environment

  • Plugin version: monorepo main (b4cc9bc)
  • Runtime: Node 22, npm 10

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Tested

  1. npx vitest run tests/unit/config tests/unit/llm — 148 passed
  2. npx tsc -p tsconfig.json --noEmit — 0 errors
  3. Manual: resolveConfig({ llm: { maxTokens: 2048, headers: { "User-Agent": "test" } } }) returns both values with zero warnings; resolveConfig({}) yields maxTokens: 1024, headers: {}

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (config template)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally

…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.
@Memtensor-AI Memtensor-AI added area:plugin OpenClaw & Hermes status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Aug 14, 2026
@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (7/7 executed). memos_local_plugin/unit: 7/7. Duration: 3s

Branch: fix/config-llm-maxtokens-headers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:plugin OpenClaw & Hermes status:in-progress Someone or AI is working on it | 人工或 AI 正在处理

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: llm.maxTokens and llm.headers are read at runtime but undeclared in config schema (boot-time unknown-key warnings)

3 participants