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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: validate provider/model compatibility in agent spawning
Adam Eivy8a30f03a08be
diff --git a/.changelog/v0.10.x.md b/.changelog/v0.10.x.mdindex 36d404e3ce..b23287d6d8 100644--- a/.changelog/v0.10.x.md+++ b/.changelog/v0.10.x.md@@ -35,10 +35,17 @@ This release introduces a structured changelog documentation system for creating### PortOS Stack Template - AI Provider Integration- **AI Toolkit Integration**: New projects created with the PortOS Stack template now include `@portos/ai-toolkit` by default-- **Provider Management**: Scaffolded projects have `/api/providers` endpoints for managing AI providers (CLI or API-based)+- **Provider Management UI**: Scaffolded projects include an AI Providers page (`/providers`) for adding, editing, testing, and deleting providers+- **Navigation Integration**: New apps have icons in the sidebar with active state highlighting for Home, AI Providers, and About routes+- **Provider Management API**: `/api/providers` endpoints for managing AI providers (CLI or API-based)- **Run Tracking**: `/api/runs` endpoints for executing and tracking AI runs- **Prompt Templates**: `/api/prompts` endpoints for managing reusable prompt templates-- **Automatic Symlink**: Template creates symlinks to PortOS's ai-toolkit package for shared functionality+- **Automatic Symlink**: Template creates symlinks to PortOS's ai-toolkit package in root, server, and client node_modules++### Create App Improvements+- **Default Directory Path**: The Create App page (`/apps/create`) now defaults to the PortOS parent directory+- **Folder Browser**: Added a folder picker button to browse and select project directories visually+- **Templates Auto-Default**: Templates page now automatically sets the target directory without requiring folder selection### Soul - Digital Twin Identity System- **Soul Documents**: New `/soul` page for managing identity scaffold documents that define persona, values, and cognitive style@@ -81,6 +88,13 @@ This release introduces a structured changelog documentation system for creating- **Easy Maintenance**: Simple process for creating and updating release notes- **Tool Integration**: Instructions for using `gh` CLI to manage releases+## 🐛 Fixes++### CoS Agent Provider/Model Validation+- **Provider Override Support**: Tasks specifying a `provider` in metadata now correctly use that provider instead of always using the active provider+- **Model Compatibility Validation**: When spawning agents, models are now validated against the target provider's model list - prevents invalid combinations like using Claude models with the Codex CLI provider+- **Graceful Fallback**: Invalid model/provider combinations fall back to the appropriate tier model for the actual provider with a warning log+## 🗑️ Removed### Dead Code Cleanupdiff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.jsindex a2a60d67e4..cf0db7ab09 100644--- a/server/services/subAgentSpawner.js+++ b/server/services/subAgentSpawner.js@@ -16,7 +16,7 @@ import { v4 as uuidv4 } from 'uuid';import { cosEvents, registerAgent, updateAgent, completeAgent, appendAgentOutput, getConfig, updateTask, addTask, emitLog } from './cos.js';import { startAppCooldown, markAppReviewCompleted } from './appActivity.js';import { isRunnerAvailable, spawnAgentViaRunner, terminateAgentViaRunner, killAgentViaRunner, getAgentStatsFromRunner, initCosRunnerConnection, onCosRunnerEvent, getActiveAgentsFromRunner, getRunnerHealth } from './cosRunnerClient.js';-import { getActiveProvider } from './providers.js';+import { getActiveProvider, getProviderById } from './providers.js';import { recordSession, recordMessages } from './usage.js';import { buildPrompt } from './promptService.js';import { registerSpawnedAgent, unregisterSpawnedAgent } from './agents.js';@@ -592,16 +592,45 @@ export async function spawnAgentForTask(task) {// Get configurationconst config = await getConfig();- const provider = await getActiveProvider();+ let provider = await getActiveProvider();if (!provider) {cosEvents.emit('agent:error', { taskId: task.id, error: 'No active AI provider configured' });return null;}+ // Check if user specified a different provider in task metadata+ const userProviderId = task.metadata?.provider;+ if (userProviderId && userProviderId !== provider.id) {+ const userProvider = await getProviderById(userProviderId);+ if (userProvider) {+ emitLog('info', `Using user-specified provider: ${userProviderId}`, { taskId: task.id });+ provider = userProvider;+ } else {+ emitLog('warning', `User-specified provider "${userProviderId}" not found, using active provider`, { taskId: task.id });+ }+ }+// Select optimal model for this taskconst modelSelection = selectModelForTask(task, provider);- const selectedModel = modelSelection.model;+ let selectedModel = modelSelection.model;++ // Validate model is compatible with provider+ if (selectedModel && provider.models && provider.models.length > 0) {+ const modelIsValid = provider.models.includes(selectedModel);+ if (!modelIsValid) {+ emitLog('warning', `Model "${selectedModel}" not valid for provider "${provider.id}", falling back to provider default`, {+ taskId: task.id,+ requestedModel: selectedModel,+ providerId: provider.id,+ validModels: provider.models+ });+ // Fall back to the appropriate tier model for this provider+ selectedModel = modelSelection.tier === 'heavy' ? provider.heavyModel :+ modelSelection.tier === 'light' ? provider.lightModel :+ provider.mediumModel || provider.defaultModel;+ }+ }emitLog('info', `Model selection: ${selectedModel} (${modelSelection.reason})`, {taskId: task.id,