* Create one agent per model in the whitelist. All agents share the * same context schema, instruction builder, and dynamic tool composer * — they only differ by which provider model runs the conversation. * * The frontend "model picker" is an "agent picker" in disguise: it * just selects which
(entry: ChatModelEntry)
| 29 | * still throw at startup. |
| 30 | */ |
| 31 | function createChatAgent(entry: ChatModelEntry) { |
| 32 | return defineAgent({ |
| 33 | name: entry.id, |
| 34 | description: `OpenPanel chat assistant (${entry.label})`, |
| 35 | model: resolveModel(entry), |
| 36 | contextSchema: chatContextSchema, |
| 37 | instruction: (context: ChatAgentContext) => buildSystemPrompt(context), |
| 38 | tools: (context: ChatAgentContext) => composeChatTools(context), |
| 39 | maxSteps: 20, |
| 40 | // Reasoning-capable models (gpt-5.x / o-series) need the |
| 41 | // `reasoning.summary` option to stream reasoning text back; the |
| 42 | // client's REASONING_MESSAGE_* events feed our `ReasoningBlock` |
| 43 | // UI. Non-reasoning models skip this block entirely. |
| 44 | ...(entry.reasoning |
| 45 | ? { |
| 46 | defaultModelOptions: { |
| 47 | reasoning: { |
| 48 | effort: 'medium', |
| 49 | summary: 'auto', |
| 50 | }, |
| 51 | }, |
| 52 | } |
| 53 | : {}), |
| 54 | // biome-ignore lint/suspicious/noExplicitAny: see block comment above |
| 55 | } as any); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Dedicated cheap agent for generating 3-5 word conversation titles. |
nothing calls this directly
no test coverage detected