fix(config): accept model thinkingLevelMap in provider config schema (#91011) [AI-assisted]#91045
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: the same Foundry Entra config-schema bug is already covered by a viable earlier PR with stronger validator-level regression coverage, and this branch adds a slightly stricter value schema than the established Canonical path: Review and land the canonical duplicate PR, or an equivalent patch that accepts the existing So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Review and land the canonical duplicate PR, or an equivalent patch that accepts the existing Do we have a high-confidence way to reproduce the issue? Yes. Current main's Foundry writer persists Is this the best way to solve the issue? No. Accepting the field is the right repair, but this branch is not the best landing path because the earlier open PR fixes the same gap without stricter values and with better validator coverage. Security review: Security review cleared: The diff only changes config schema/tests and a generated baseline hash; it adds no dependency, workflow, secret, install, or code-execution surface. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 919befbbb63c. |
|
Closing as superseded, per @clawsweeper's review. The same Foundry Thanks for the review — happy to help get #91037 over the line instead. |
Summary
The strict Zod schema that validates persisted provider model entries (
models.providers.*.models[]) did not allow athinkingLevelMapfield, even though it is a first-class part of the model definition (present on the runtime type and the read-path TypeBox schema). As a result, any config write that includes a modelthinkingLevelMapfailed.strict()validation and the atomic write rolled back.This bites the built-in Microsoft Foundry Entra ID onboarding: its auth writer emits
thinkingLevelMapon each model entry, so onboarding passes the connection test and then can't persist — leaving the provider unconfigured with no supported way to finish (#91011).Root cause
thinkingLevelMapis part of the model definition: runtime typeThinkingLevelMap(packages/llm-core/src/types.ts) and the read-path schemaThinkingLevelMapSchema(src/agents/sessions/model-registry.ts).ModelDefinitionSchema(src/config/zod-schema.core.ts), which validatesmodels.providers.*.models[]on save, is.strict()and was missing the key → unrecognized key → the atomic config write rolls back. (normalizeResolvedModelre-adds the field in memory at request time, so it never surfaces on the read path — only on write.)Changes
src/config/zod-schema.core.ts— addModelThinkingLevelMapSchema(mirrors the canonical 7ModelThinkingLevelkeys exactly:off/minimal/low/medium/high/xhigh/max, valuesstring | null, strict) and wire it intoModelDefinitionSchema. Add bidirectionalAssertAssignableguards tyingz.infer<…>to the canonicalThinkingLevelMaptype so the two can't drift.src/config/zod-schema.models.test.ts— schema accepts a provider model withthinkingLevelMap.extensions/microsoft-foundry/index.test.ts— Foundry auth writer emits thethinkingLevelMapshape on its model entry.docs/.generated/config-baseline.sha256— regenerated config doc baseline to reflect the new schema field (pnpm config:docs:gen).One logical change; no new dependency.
Verification (local, Node 22)
Real behavior proof
Reproduced end-to-end through the real
openclaw config validatecommand (no Azure/Entra account required — the bug is the config write/validate path).Behavior addressed: persisted provider model config containing
thinkingLevelMapwas rejected by strict validation, rolling back the atomic write (blocks Microsoft Foundry Entra onboarding from persisting).Real environment tested: local OpenClaw CLI built from source on macOS arm64, Node v22.22.3, run against an isolated config file via
OPENCLAW_CONFIG_PATH.Exact steps or command run after this patch: wrote
/tmp/openclaw-foundry-repro.jsonwith amicrosoft-foundryprovider model carrying athinkingLevelMap(the shape the Entra onboarding writer emits), then ran the real CLI command:Config file used:
{ "models": { "providers": { "microsoft-foundry": { "baseUrl": "https://example.services.ai.azure.com/openai/v1", "api": "openai-completions", "models": [ { "id": "gpt-5.4", "name": "gpt-5.4", "reasoning": true, "thinkingLevelMap": { "off": "none", "minimal": null, "low": "low", "medium": "medium", "high": "high" } } ] } } } }Before evidence: on
main(unfixed), the same command rejected the config and exited 1:(Same rejection the issue reporter saw as
Unrecognized key: "thinkingLevelMap".)Evidence after fix: terminal output of the same command on this branch:
Observed result after fix: the config with a model
thinkingLevelMapnow passes validation and persists; the onboarding write no longer rolls back.What was not tested: the live Azure Foundry Entra managed-identity onboarding flow (no Entra resource available). Validated through the config write/validate path that the onboarding writer feeds, which is exactly where the rollback occurred.
AI-assisted
This change was AI-assisted. It was implemented by one model and independently reviewed by a different model (code read end-to-end; findings applied: removed a test boundary-escaping import, dropped a non-canonical schema key, added the type guards, regenerated the config baseline). I understand the code and ran the proof above myself. Prompts/session log available on request.
Closes #91011
Notes
Net: +72 / −3 across 4 files (1 schema, 2 tests, 1 generated config baseline).