AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(agents): new agents can answer on a fresh cloud account (#17087)
Hazem Adeled8881ea1750
diff --git a/brain/knowledge/ai-intelligence/ai-providers.md b/brain/knowledge/ai-intelligence/ai-providers.mdindex 655d26b8251..dd6441df99f 100644--- a/brain/knowledge/ai-intelligence/ai-providers.md+++ b/brain/knowledge/ai-intelligence/ai-providers.md@@ -75,6 +75,7 @@ after a file without chat keys it seeds the chat list from the live flow list.**Specific model** — a model a builder picks directly from one key (`{provider, configId, model}`), as opposed to a tier. The admin switch `platform_configuration.aiSpecificModelsVisible` (Tiers tab, "Visible to builders") hides them from builders. _Avoid_: "Advanced" (an early mockup word for the same section)### Gotchas+- **The Activepieces credits row is created lazily, so any read of provider rows must call `ensureManagedProviderRow` first.** `listVisibleRows` and `findAvailableChatProviderRow` both do. A brand-new platform has no row until one of them runs. Before AI-173, agent creation read the table directly, so a new cloud signup whose first AI action was "New agent" got an agent with no model, and its first message failed with a 409. A test that seeds the row with `mockAndSaveAIProvider` can't catch this, so cover the fresh-platform path without seeding.- **Every AI Center page links its admin guide from the header, through `adminPageResources` (`packages/web/src/app/components/admin/admin-page-resources.ts`).** `aiProviders` → `admin-guide/guides/setup-ai-providers` (Providers and the key page), `aiTiers` → `ai-tiers`, `aiCapabilities` → `ai-capabilities`, `aiUsage` → `ai-usage` (overview, list and detail). A new AI Center page needs a guide under `docs/admin-guide/guides/`, an entry in the docs.json **AI Center** group, and a `resources=` on its `AdminPageHeader`.- **A new provider shows "—" for context and price until the catalog is republished from `main`.** Its `MODELS_DEV_PROVIDER` entry only takes effect when the weekly `sync-model-catalog` workflow runs on `main` (trigger it by hand after the merge), and the API caches the catalog for 24h. Even then only ids models.dev knows fill in: of NVIDIA's 85 hosted models about 26 match, and its prices are $0 because the hosted catalogue is free.- **The AI usage read API (`/v1/ai-usage/*`) works in UTC days and scales today's partial day inside the SQL.** Every previous-range sum is multiplied by a weight that is below 1 only on the day matching today, so totals, cards, lists and related items all compare the same way. Scaling after the query, in TypeScript, can't reach per-item numbers and makes the views disagree.diff --git a/packages/server/api/src/app/ai/ai-provider-service.ts b/packages/server/api/src/app/ai/ai-provider-service.tsindex cbc347e9df7..d9a1d695704 100644--- a/packages/server/api/src/app/ai/ai-provider-service.ts+++ b/packages/server/api/src/app/ai/ai-provider-service.ts@@ -690,6 +690,9 @@ function hasManagedKey(auth: AIProviderAuthConfig | null): auth is AIProviderAut}async function findAvailableChatProviderRow({ platformId, scope, log }: { platformId: PlatformId, scope: ProviderScope, log: FastifyBaseLogger }): Promise<AIProviderSchema | null> {+ if (flagService(log).aiCreditsEnabled()) {+ await ensureManagedProviderRow({ platformId })+ }const candidates = await aiProviderRepo().findBy([{ platformId, enabledForChat: true },{ platformId, provider: AIProviderName.ACTIVEPIECES },diff --git a/packages/server/api/test/integration/ee/agent/agent-controller.test.ts b/packages/server/api/test/integration/ee/agent/agent-controller.test.tsindex 820d7b68307..2c743ad59dc 100644--- a/packages/server/api/test/integration/ee/agent/agent-controller.test.ts+++ b/packages/server/api/test/integration/ee/agent/agent-controller.test.ts@@ -88,6 +88,21 @@ describe('agent crud', () => {}})+ it('fills in the default tier on a fresh platform whose Activepieces credits row was never listed', async () => {+ process.env.AP_OPENROUTER_PROVISION_KEY = 'test-provision-key'+ try {+ const ctx = await context()++ const agent = await createAgent(ctx)++ expect(agent.draft.modelName).toBe('smart')+ expect(agent.draft.provider).toBe(AIProviderName.ACTIVEPIECES)+ }+ finally {+ delete process.env.AP_OPENROUTER_PROVISION_KEY+ }+ })+it('keeps a model the request did name, even where a default was available', async () => {const ctx = await context()await mockAndSaveAIProvider({ platformId: ctx.platform.id, provider: AIProviderName.OPENROUTER, enabledForChat: true })diff --git a/packages/web/src/features/chat/lib/use-chat.ts b/packages/web/src/features/chat/lib/use-chat.tsindex 94c863baed8..6339084f70b 100644--- a/packages/web/src/features/chat/lib/use-chat.ts+++ b/packages/web/src/features/chat/lib/use-chat.ts@@ -866,7 +866,10 @@ export function useAgentChat({setOptimisticUserMessage(null);updateSendStatus({type: 'error',- message: convError.message ?? 'Failed to start conversation',+ message: api.extractServerErrorMessage(+ convError,+ 'Failed to start conversation',+ ),});return;}@@ -928,7 +931,10 @@ export function useAgentChat({} else {updateSendStatus({type: 'error',- message: sendError.message ?? 'Failed to send message',+ message: api.extractServerErrorMessage(+ sendError,+ 'Failed to send message',+ ),});}}