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

fix scheduled tasks spawning claude with a stale hardcoded opus model

[._.]/ Adam Eivy5e26341dd4ca
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 40535d2476..edf5275f4a 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -3,6 +3,7 @@
## CoS Agents
- **[issue-2190] OpenCode Ollama providers now accept any --model flag.** The static `OPENCODE_CONFIG_CONTENT` lacked a models map, so OpenCode rejected every model with "not valid" and the agent sat idle. The config is now built dynamically at spawn time with the effective model declared, fixing the TUI eval path for local Ollama models.
+- **Scheduled improvement tasks with no configured model now follow the active provider's default instead of a stale hardcoded one.** When a self-improvement or managed-app improvement task had no explicit model in its schedule config, the generator pinned a hardcoded `claude-opus-4-5-20251101` into the task — a model that had since dropped out of the `claude-code-tui` provider config, so the scheduler spawned `claude --model claude-opus-4-5-20251101` even after the provider default moved to Opus 4.8. Since a per-task model pin is honored above the provider default (it's passed straight through to the CLI), that stale literal overrode the configured default on every scheduled run. The generator no longer pins a literal: with no configured model it leaves the task's model unset, so model selection resolves the active provider's tier/default model at spawn time and always uses a model the provider actually lists. An explicit per-task or per-schedule model pin still wins as before. (`server/services/cosTaskGenerator.js`)
- **An explicit per-task model pin is now always honored — no more silent, expensive downgrades.** When you set a specific model on a CoS task, PortOS validated it against the provider's `models` list and, on any mismatch, *silently fell back to the provider's default (heaviest) model*. Because `claude-code-tui` lists the dated id `claude-haiku-4-5-20251001` while `claude-code` lists the undated `claude-haiku-4-5`, picking "haiku" on the TUI provider quietly ran **Opus** instead. Explicit user-specified models are now passed through to the CLI even when they're not in the convenience list (the CLIs accept any valid id; a genuine typo surfaces as a provider error rather than a costly silent substitution). Auto-selected models still fall back to the tier default as before.
- **Worktree tasks now default to opening a PR instead of auto-merging to your default branch.** A CoS task run in an isolated worktree with "Open PR" off merges its commits straight back to the main development branch on completion — fine for trusted agents, dangerous for unreviewed local-model work. Creating a worktree task now defaults "Open PR" on (in the UI, enabling Worktree checks it; via the API, a worktree user-task without an explicit `openPR` defaults to `true`). You can still turn it off per-task for a quick auto-merge, and internal automation (autopilot, self-improvement) keeps its existing auto-merge behavior so nothing starts silently waiting on a human to merge a PR.
diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.js
index 59fabed592..af0ed78a42 100644
--- a/server/services/cosTaskGenerator.js
+++ b/server/services/cosTaskGenerator.js
@@ -1288,10 +1288,14 @@ export async function generateSelfImprovementTaskForType(taskType, state) {
metadata.provider = interval.providerId;
metadata.providerId = interval.providerId;
}
+ // Only pin a model when the schedule config explicitly sets one. With no
+ // pin, leave metadata.model unset so selectModelForTask resolves the ACTIVE
+ // provider's tier/default model at spawn time — never a hardcoded literal.
+ // (A stale literal here once pinned an opus release that had since dropped
+ // out of the provider config, spawning claude with a --model the provider
+ // no longer lists.)
if (interval.model) {
metadata.model = interval.model;
- } else {
- metadata.model = 'claude-opus-4-5-20251101';
}
const approval = await resolveConfidenceApproval(state, `self-improve:${taskType}`, `Task self-improve:${taskType}`);
@@ -1768,11 +1772,11 @@ export async function generateManagedAppImprovementTaskForType(taskType, app, st
metadata.provider = interval.providerId;
metadata.providerId = interval.providerId;
}
+ // Only pin a model when the schedule config explicitly sets one; otherwise
+ // leave it unset so selectModelForTask resolves the active provider's tier/
+ // default model at spawn time (see note in generateSelfImprovementTaskForType).
if (interval.model) {
metadata.model = interval.model;
- } else if (!metadata.provider) {
- // Only default to Claude when no per-stage provider overrides the selection
- metadata.model = 'claude-opus-4-5-20251101';
}
const approval = await resolveConfidenceApproval(state, `app-improve:${taskType}`, `Task app-improve:${taskType} for ${app.name}`);
diff --git a/server/services/cosTaskGenerator.test.js b/server/services/cosTaskGenerator.test.js
index ece7154b1b..98972462d9 100644
--- a/server/services/cosTaskGenerator.test.js
+++ b/server/services/cosTaskGenerator.test.js
@@ -299,6 +299,31 @@ describe('swarm block wiring', () => {
});
});
+// A scheduled/self-improvement task with no configured model must NOT pin a
+// hardcoded model literal — it must leave metadata.model unset so
+// selectModelForTask resolves the ACTIVE provider's tier/default model at spawn
+// time. A stale literal here once pinned `claude-opus-4-5-20251101`, which had
+// dropped out of the claude-code-tui provider config, so the scheduler spawned
+// `claude --model claude-opus-4-5-20251101` — a model the provider no longer
+// listed. The only assignment to metadata.model in either generator must come
+// from `interval.model`.
+describe('improvement-task model is never a hardcoded literal', () => {
+ it('does not assign a hardcoded claude-* model literal to metadata.model', () => {
+ expect(GEN_SRC).not.toMatch(/metadata\.model\s*=\s*['"]claude-/);
+ });
+
+ it('sets metadata.model only from config-driven fields, never a string literal', () => {
+ const assignments = GEN_SRC.match(/metadata\.model\s*=\s*[^;]+/g) || [];
+ expect(assignments.length).toBeGreaterThan(0);
+ for (const line of assignments) {
+ // Every assignment must read from schedule/stage config (interval.model,
+ // stage0.model, …) — never a bare quoted model id.
+ expect(line).not.toMatch(/metadata\.model\s*=\s*['"]/);
+ expect(line).toMatch(/metadata\.model\s*=\s*\w+\.model/);
+ }
+ });
+});
+
describe('exceedsMaxSpawns', () => {
it('is false below the ceiling and true at/above it — no mutation', () => {
expect(exceedsMaxSpawns(task('a', { totalSpawnCount: 0 }))).toBe(false);