( fullAgentId: string, model: string, )
| 181 | * 4. The model is in that agent's allowed model set |
| 182 | */ |
| 183 | export function isFreeModeAllowedAgentModel( |
| 184 | fullAgentId: string, |
| 185 | model: string, |
| 186 | ): boolean { |
| 187 | const { publisherId, agentId } = parseAgentId(fullAgentId) |
| 188 | |
| 189 | // Must have a valid agent ID |
| 190 | if (!agentId) return false |
| 191 | |
| 192 | // Must be either internal (no publisher) or from codebuff |
| 193 | if (publisherId && publisherId !== 'codebuff') return false |
| 194 | |
| 195 | // Get the allowed models for this agent |
| 196 | const allowedModels = FREE_MODE_AGENT_MODELS[agentId] |
| 197 | if (!allowedModels) return false |
| 198 | |
| 199 | // Empty set means programmatic agent (no LLM calls expected) |
| 200 | // For these, any model check should fail (they shouldn't be making LLM calls) |
| 201 | if (allowedModels.size === 0) return false |
| 202 | |
| 203 | // Exact match first |
| 204 | if (allowedModels.has(model)) return true |
| 205 | |
| 206 | // OpenRouter may return dated variants (e.g. "minimax/minimax-m2.7-20260211") |
| 207 | // so also check if the returned model starts with any allowed model prefix. |
| 208 | for (const allowed of allowedModels) { |
| 209 | if (model.startsWith(allowed + '-')) return true |
| 210 | } |
| 211 | |
| 212 | return false |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * Check if an agent should be free (no credit charge) for small requests. |
no test coverage detected