1. AgentDetailModal – fix provider not being pre-selected on edit open:
- Add resolveProviderValue() that does exact → case-insensitive → partial
match between stored provider string and connectedProviders list
- Re-resolve provider in a second useEffect once providers load from API
- Add safety-net SelectItem for stored value not found in providers list
2. AgentCreateModal – refactor Deploy Agent form:
- Fix Provider + Model fields layout (grid-cols-2 with w-full truncate to
prevent overflow/merging)
- Add Wand2 'Auto-fill' button next to Agent Name field that calls
agentCompiler.compile (existing LLM endpoint) with name+description as
spec — fills role, model, temperature, systemPrompt automatically
- Add Sparkles hint text explaining the magic wand functionality
- Auto-select first provider/model when data loads
- All fields use font-mono + proper label spacing
3. Both modals – MaxTokens auto-fill from Ollama API:
- Add getOllamaModelInfo() in gateway-proxy.ts: calls Ollama /api/show,
extracts {arch}.context_length from model_info, returns contextLength +
parameterSize, family, quantization, capabilities
- Add ollama.modelInfo tRPC query endpoint in routers.ts (input: modelId)
- Both modals query trpc.ollama.modelInfo on model selection change
- Auto-set maxTokens to context_length from API (262144 for kimi-k2.5 etc.)
- Show 'max N from API' hint + clickable link to set full context window
- Loading spinner while fetching model info
Problems fixed:
1. 401 unauthorized on chat — OLLAMA_API_KEY was not set in containers
- Created docker/.env with real API key
- Added OLLAMA_BASE_URL + OLLAMA_API_KEY to control-center in docker-compose.yml
2. AgentDetailModal/AgentCreateModal showed hardcoded providers list
(Ollama, OpenAI, Anthropic, Mistral, Groq) regardless of what is configured
- Removed const PROVIDERS = [...] from both modals
- Now loads providers via trpc.config.providers (server-side)
- Only shows providers that are actually configured in env
3. Settings.tsx had API key hardcoded in frontend source code (security issue)
- API key removed from frontend
- New trpc.config.providers endpoint returns masked key (first 8 chars + ***)
- Shows red warning badge 'NO KEY — chat will fail' if key is missing
- Base URL read from server env, not hardcoded
New tRPC endpoint: config.providers
- Returns list of configured providers with name, baseUrl, hasKey, maskedKey
- Provider name auto-detected from URL (ollama.com → 'Ollama Cloud', etc.)
- AgentDetailModal: load real models from API with loading indicator;
fallback to current agent model when API unavailable; show count badge
- AgentCreateModal: remove broken provider-filter on models list;
add loading indicator and disabled state during fetch; show count badge
- gateway/orchestrator: add resolveModel() — validates desired model
against LLM API before use; auto-fallback to first available model
to prevent 401/404 errors (fixes glm-5 unauthorized in chat)
- gateway/orchestrator: add ModelWarning field to ChatResult struct
- gateway-proxy.ts: add modelWarning field to GatewayChatResult
- Chat.tsx: display modelWarning as amber badge next to model name
- todo.md: add Phase 16 section with bug fixes and tech debt notes