Repository navigation
AI prompt pipeline: key save, live model, honest outcomes (6/7) - #47
Merged
Merged
Conversation
… outcomes
The feature was dead three independent ways (forensic audit on-branch):
the settings key field had NO save handler (typed keys went nowhere); the
default model claude-3-5-haiku-20241022 was retired 2026-02 and 404s (the
second death-by-model-retirement — the previous default was also retired);
and every failure reported as success — the 202-accept pattern meant the UI
printed "Applied to the console" while "no key"/"bad key"/"404 model"
died in the serial log.
- UI: #aiKey saves on change via /api/config (masked "****" echo and empty
values are never sent back); placeholder now sk-ant-…; Enter commits.
- Model: default -> claude-haiku-4-5, plus an NVS migration in loadConfig —
any config save pins the then-default model, so existing devices carry the
retired id and a new default alone can never heal them. secrets.h.example
updated too.
- Honest outcomes: the worker records each job's result; new
GET /api/prompt/status {busy, jobs, lastOk, lastError} (seq-guarded torn-
read-safe cross-task copy); engine.sendPrompt polls it after the 202 and
resolves with the REAL outcome; the UI shows the device's own error text
verbatim instead of unconditional success. dev_server.js mocks the
endpoint so the mock stays faithful.
Verified: browser run against the mock (chip click holds "Interpreting…"
until the worker finishes, key save toasts); flashed to the C3 — status
endpoint live, NVS model migrated to claude-haiku-4-5 on first boot;
native tests pass.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… a retired one Found on hardware: a freshly flashed C3 reported aiModel "claude-3-5-haiku-20241022" (retired 2026-02-19, 404s at the API) even though the prompt-pipeline commit had moved the default to claude-haiku-4-5. Root cause: the default lived in two separate literals. The prompt-pipeline commit updated the loadConfig() getString fallback and added a retired-id migration there, but on a factory-fresh board the NVS namespace doesn't exist, so loadConfig() returns at prefs.begin() before either runs — and the Config struct initializer in storage.h still held the retired id. The first config save (provisioning WiFi) then persisted it to NVS. The prompt-pipeline commit's "migration confirmed on hardware" was checked on a board that already had NVS, so the fresh-board path was never exercised. - AI_MODEL_DEFAULT in constants.h is now the single source: the struct initializer, the loadConfig() fallback, and the migration target all use it, so they cannot drift apart again (the same pattern storage.h already uses to seed the gamma default from LED_GAMMA). - dev_server.js and two API_V2.md examples no longer show the retired claude-3-5-sonnet-20241022. Model IDs checked against the Claude API reference: claude-haiku-4-5 is Active; claude-3-5-haiku-20241022 (retired Feb 19 2026) and claude-3-5-sonnet-20241022 (retired Oct 28 2025) are retired. The firmware's raw request shape (x-api-key, anthropic-version 2023-06-01, model / max_tokens / messages, reading content[0].text) matches the documented one. Verified: 82/82 native tests; flashed to the C3, which reports aiModel "claude-haiku-4-5" after reboot (the persisted retired id is migrated on load). Not verified end-to-end against the API: no key was used. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Follow-up from review of the default-model fix, which left two ways to end up with a retired or empty model: - The dev-secrets override in main.cpp assigned DEV_AI_MODEL unconditionally, after loadConfig() and so after its migration. A secrets.h copied from the old example (which shipped claude-3-5-sonnet-20241022) kept running a retired id, and any settings save persisted it. An empty DEV_AI_MODEL blanked the model, unlike the length-guarded SSID/key overrides next to it. - POST /api/config stored any string: a retired id lived until the next reboot's migration, and an empty string was stored and never fell back to the default, because the key now existed. The migration is now a normalizeAiModel() helper (empty or retired -> AI_MODEL_DEFAULT) applied on all three paths: NVS load, the /api/config update and the dev override, which is now length-guarded like its siblings. Verified: firmware builds, including a build with src/secrets.h present to compile the otherwise-dormant override path; 82/82 native tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 12, 2026
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.
What
The AI prompt feature was dead three independent ways; this fixes all three.
claude-haiku-4-5, with a load-time migration for retired IDs already stored on a device. The default is also a singleAI_MODEL_DEFAULTconstant: it used to live in two places that drifted apart, and fresh boards booted the retired model.GET /api/prompt/statusreports the worker's real outcome, and the UI shows the device's actual error text instead of "Applied".Review follow-up: empty or retired model IDs are normalized on every path a model enters the config: NVS load,
POST /api/config, and the dev-secrets override. The override could previously re-introduce a retired ID from an oldsecrets.h, and an empty value could be stored with no fallback.Review notes
claude-haiku-4-5is active, andclaude-3-5-haiku-20241022/claude-3-5-sonnet-20241022are retired.content[0].text. That is fine for Haiku 4.5 (no thinking by default), but a model with thinking on by default would need the parser to find the first text block.Verification
Built and tested on this branch alone. This stacked state is new, so it was verified independently rather than assumed: 81/81 native tests pass, the firmware builds for
seeed_xiao_esp32c3(65.3% of the app partition, the new 1.75 MB slot), and the web UI JS passesnode --check.On hardware: a fresh board now reports
claude-haiku-4-5, and the status endpoint responds. Not tested end-to-end against the API (no key).🤖 Generated with Claude Code
The stack (merge top to bottom):