Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): line-anchor + status-anchor the terminal model-id signal

[._.]/ Adam Eivy767dcf893659
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 6ab35574e4..43be7cca52 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -12,7 +12,7 @@
## Changed
-- **AI provider failures now log the actual reason inline.** The `🤖 AI provider error detected` line in pm2 logs previously printed only the provider name and run id, so diagnosing a failed run meant opening `data/runs/<id>/metadata.json` to find the captured error. It now includes the model, error category, exit code, and the (single-line, capped) error text — e.g. `… Claude Code CLI (claude-opus-4-8) [model-not-found] exit=1 - run f95b8af2: API Error (claude-opus-4-8): 400 The provided model identifier is invalid.` — so the "why" is visible at a glance. The full untruncated text still lives in the run record. (`server/services/autoFixer.js`)
+- **AI provider failures now log the actual reason inline.** The `🤖 AI provider error detected` line in pm2 logs previously printed only the provider name and run id, so diagnosing a failed run meant opening `data/runs/<id>/metadata.json` to find the captured error. It now includes the model, error category, exit code, and the (single-line, capped) error text — e.g. `… Claude Code CLI (claude-opus-4-8) [model-not-found] exit=1 - run f95b8af2-95fd-…: API Error (claude-opus-4-8): 400 The provided model identifier is invalid.` — so the "why" is visible at a glance. The full untruncated text still lives in the run record. (`server/services/autoFixer.js`)
- **Deploying a LoRA checkpoint with no preview now auto-renders one.** A training run only writes preview thumbnails at the `sampleEvery` cadence, so a checkpoint whose step doesn't land on it — most often the final step (e.g. step 1188 with sampleEvery 300) — showed "no preview" in the picker, including on the deployed card. Promoting such a checkpoint now renders a thumbnail in the background from the just-deployed LoRA (the run's neutral trigger prompt + seed, on the LoRA's own 9B/4B base) and joins it to the checkpoint by step, so the deployed option gets a real image instead of a blank. The render is fire-and-forget — promote stays responsive and a render failure (OOM, restart) never fails the deploy, since the LoRA is already registered. The picker backstop-polls after promoting a preview-less checkpoint to surface the thumbnail once it's ready (~minutes on 9B), unmount-guarded. (`server/services/loraTraining/index.js` `ensureCheckpointPreview`, `client/src/components/loraTraining/CheckpointPicker.jsx`)
diff --git a/server/lib/aiToolkit/errorDetection.js b/server/lib/aiToolkit/errorDetection.js
index 81761d906d..7cce2e949e 100644
--- a/server/lib/aiToolkit/errorDetection.js
+++ b/server/lib/aiToolkit/errorDetection.js
@@ -112,18 +112,28 @@ const IMMEDIATE_FALLBACK_SIGNALS = [
},
{
// Claude Code renders a non-recoverable *model id* rejection inline as
- // `API Error (<model>): 400 The provided model identifier is invalid…`
+ // `⏺ API Error (<model>): 400 The provided model identifier is invalid…`
// (Bedrock) or `API Error: 404 … not_found_error` (Anthropic) and then sits
// at an unanswered prompt — it does NOT auto-retry the way it does a 429/500.
// Without an early-fail signal the one-shot TUI runner idles out, reports
// success, and scrapes the error screen as a bogus "response" (which then
// trips downstream guards like the manuscript-reformat integrity check).
- // Anchored on the literal `API Error` + a 400/404 status so an agent merely
- // *printing* the phrase "model identifier is invalid" in its own work output
- // can't trip it; terminal + model-specific, so failing the run immediately
- // (to fall back / surface an actionable error) never aborts a run that would
- // have recovered.
- pattern: /API Error[^\n]{0,100}\b(?:400|404)\b[^\n]{0,160}(?:model identifier is invalid|not[_\s]?found)/i,
+ //
+ // Two precision constraints keep this from killing a long-running CoS agent
+ // (the agent spawn paths also stop the run on this signal) that merely echoes
+ // such a line in its OWN work output:
+ // 1. Line-anchored (`^…/m`, like the `Now using extra usage` signal above)
+ // — Claude Code prints the error on its own line, so the real signal is
+ // at a line start (or the 512-char buffer's slice boundary, which `^`
+ // also matches); a full error line quoted mid-sentence in agent prose
+ // is not.
+ // 2. The 400/404 status must immediately follow the `API Error[(model)]:`
+ // prefix — so a retryable line like `API Error: 429 … 404 not found`
+ // (whose 404 is incidental) does not match and a run Claude Code would
+ // auto-retry isn't aborted.
+ // Terminal + model-specific, so failing the run immediately (to fall back /
+ // surface an actionable error) never aborts a run that would have recovered.
+ pattern: /^\s*(?:⏺\s*)?API Error(?:\s*\([^)]*\))?:\s*(?:400|404)\b[^\n]{0,160}(?:model identifier is invalid|not[_\s]?found)/im,
category: ERROR_CATEGORIES.MODEL_NOT_FOUND,
message: 'Provider rejected the configured model id',
suggestedFix: 'The provider does not recognize this model id — check the model name/availability for this provider; retrying with a fallback model.'
diff --git a/server/lib/aiToolkit/errorDetection.test.js b/server/lib/aiToolkit/errorDetection.test.js
index 7a6bb48ff2..f5526fc08b 100644
--- a/server/lib/aiToolkit/errorDetection.test.js
+++ b/server/lib/aiToolkit/errorDetection.test.js
@@ -185,6 +185,19 @@ describe('Error Detection', () => {
// in its own output — that must not kill its run.
expect(detectImmediateFallbackSignal('The Bedrock backend says the model identifier is invalid when you pass a bare id.')).toBeNull();
});
+
+ it('does NOT trip on a full error line quoted mid-sentence in agent prose (line-anchored)', () => {
+ // A CoS agent summarizing the bug echoes the complete error line inside a
+ // sentence — the agent spawn paths stop the run on this signal, so a
+ // mid-line echo must not match (only a real line-start error does).
+ expect(detectImmediateFallbackSignal('I fixed the `API Error (claude-opus-4-8): 400 The provided model identifier is invalid` bug in the runner.')).toBeNull();
+ });
+
+ it('does NOT trip on a retryable 429 line that incidentally contains 404 (status anchored to the prefix)', () => {
+ // The 400/404 must immediately follow the `API Error[(model)]:` prefix, so a
+ // 429 whose body merely mentions "404 ... not found" stays a retry, not a fail.
+ expect(detectImmediateFallbackSignal('API Error: 429 too many requests for the 404 page not found endpoint')).toBeNull();
+ });
});
describe('extractWaitTime', () => {