Merged
Size
M
Change Breakdown
Bug Fix50%
Feature30%
Performance10%
Refactor10%
#28108fix(ai-builder): Paginate list-credentials tool and drop unused fields

Credential list pagination shipped

The AI builder's list-credentials tool now supports pagination, letting admins with large credential vaults query their setup without hitting prompt length limits.

When admins with many credentials tried to list their credentials through Instance AI, they hit a wall: the prompt grew too long and the request failed. The root cause was straightforward — every credential carried timestamps and metadata into the AI prompt, stacking up unnecessary token cost with each entry.

The fix strips the list tool down to the essentials: id, name, and type per credential. A new pagination layer sits on top, with a default limit of 50 and a hard cap of 200, plus a total count so the AI knows how many pages remain. Admins can now ask the AI to list all credentials and it will page through them in chunks rather than choking on a single overloaded prompt.

Behind the scenes, the CredentialSummary type lost its createdAt and updatedAt fields entirely. The field stays on the internal interface for setup-workflow sorting, but it never reaches the AI prompt. For single credential lookups via get-credential, the full detail including timestamps remains available — the cleanup targeted the list endpoint specifically.

The change lives in the n8n instance-ai package, touching the AI builder tools that power the in-app AI assistant.

View Original GitHub Description

Summary

  • Adds limit/offset pagination to the list-credentials tool (default 50, max 200) with a total count, so the AI can page through large credential sets instead of loading everything into the prompt
  • Drops createdAt from CredentialSummary (no consumer uses it) and strips updatedAt from the tool output (kept on the interface for internal sorting in setup-workflow.service.ts)
  • Only exposes id, name, type to the AI prompt — reducing per-credential token cost

Fixes the "prompt too long" error for admins with many credentials.

Review / Merge checklist

  • Tests pass (8 new tests for pagination + 61 related tests green)
  • CredentialDetail still carries createdAt/updatedAt for get-credential single lookups
  • setup-workflow.service.ts sorting by updatedAt is unaffected (field stays on CredentialSummary)

Test plan

  • As an admin with 50+ credentials, open Instance AI and ask it to list credentials — verify it returns a paginated result with total
  • Verify the AI can paginate through all credentials using offset
  • Verify filtering by type still works
  • Verify no timestamps appear in the AI's credential list output
© 2026 · via Gitpulse