n8n/packages/@n8n/instance-ai
Bernhard Wittmann e234d5c3f4
spike: prove sandbox-built app can call back into a real n8n workflow
Vertical slice for the 'Apps as an Instance AI artifact' design (see the
Notion architecture page and goals/webpage-node/plan.md on
hackweek-n8nable-planning). Proves two previously-unverified assumptions
against a real local sandbox stack and a real n8n instance:

1. The n8n-sandbox-service can actually run npm install + npm run build
   for a Vite+React app (undocumented until now).
2. A sandbox-built app, served by n8n at /apps/:namespace/, makes a live
   fetch call to a real n8n workflow execution and renders the real
   response — confirmed visually in a real browser.

Adds a real (typechecked) apps tool + app-builder skill + serving route,
following existing Instance AI tool/skill conventions, plus the two
standalone scripts used to validate the above. See SPIKE.md for what's
proven, what's real code vs. validation-only, and the deliberate shortcuts
(in-memory app registry, no auth, no bindings enforcement, no shadcn/theme,
no live HMR) that keep this scoped as a spike.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 22:09:34 +02:00
..
docs feat(core): Allow Instance AI to search past conversations (#37478) 2026-09-04 14:48:24 +00:00
evaluations feat(core): Guide Instance AI credential selection (#37447) 2026-09-04 13:04:42 +00:00
knowledge-base/reference fix(core): Detect invalid Slack Block Kit payloads in AI Assistant builds (#37217) 2026-08-27 12:46:19 +00:00
scripts fix(core): Harden Daytona snapshot publishing with pruning and error recovery (no-changelog) (#36600) 2026-08-26 07:29:26 +00:00
skills spike: prove sandbox-built app can call back into a real n8n workflow 2026-09-07 22:09:34 +02:00
src spike: prove sandbox-built app can call back into a real n8n workflow 2026-09-07 22:09:34 +02:00
.gitignore fix(ai-builder): Bound eval lane requests and stop abandoned mocked executions (no-changelog) (#35228) 2026-08-06 08:23:37 +00:00
CLAUDE.md docs: Align Instance AI documentation with current architecture (#37032) 2026-08-25 14:00:06 +00:00
eslint.config.mjs build(core): Update Instance AI dependencies (#36635) 2026-08-24 13:35:16 +00:00
eval-run.log test(core): Extend Instance AI intent eval fixtures (no-changelog) (#33224) 2026-07-07 12:49:32 +00:00
eval-smoke.log test(core): Extend Instance AI intent eval fixtures (no-changelog) (#33224) 2026-07-07 12:49:32 +00:00
package.json 🚀 Release 2.37.0 (#36986) 2026-08-25 07:32:14 +00:00
README.md docs: Align Instance AI documentation with current architecture (#37032) 2026-08-25 14:00:06 +00:00
tsconfig.build.json feat(core): Guide Instance AI credential selection (#37447) 2026-09-04 13:04:42 +00:00
tsconfig.json feat(core): Improve Instance AI model experiments (no-changelog) (#35034) 2026-08-13 10:15:03 +00:00
vite.config.ts refactor(core): Remove Instance AI orchestration delegate tool (no-changelog) (#33556) 2026-07-07 09:15:26 +00:00

@n8n/instance-ai

Instance AI is the agent runtime behind the AI assistant experience in n8n. It lets users ask for help with workflows, executions, credentials, nodes, and workflow building from inside an n8n instance.

The package contains the agent prompts, tool registry, workflow-builder logic, workspace adapters, tracing helpers, and evaluation harnesses. The HTTP API, database entities, settings, and n8n service adapters live in packages/cli/src/modules/instance-ai.

What It Does

Instance AI is built around a deep-agent loop:

  • An orchestrator agent receives the user's request and maintains the plan.
  • Most work runs in the orchestrator. Eval setup uses a focused background agent.
  • Eval data preparation runs synchronously in the orchestrator.
  • Domain tools read and update n8n resources through backend adapters.
  • Observational memory condenses long conversations.
  • Workflow building runs in a sandbox workspace, validates generated TypeScript, and submits the workflow through the n8n backend.

The workflow builder requires sandboxing. The default provider is the n8n sandbox service. Daytona remains an explicit provider for environments that still need it.

Running Locally

Instance AI is a backend module, so run it through n8n rather than this package directly.

1. Start the n8n Sandbox Service

From the repo root:

TESTCONTAINERS_REUSE_ENABLE=true pnpm --filter n8n-containers services \
  --services sandbox \
  --network n8n-instance-ai-dev \
  --name n8n-svc-sandbox

This starts the sandbox API and runner containers and writes the host-reachable sandbox environment variables to packages/cli/bin/.env. You can verify the service from any terminal:

SANDBOX_PORT=$(docker port n8n-svc-sandbox-sandbox-api 8080/tcp | sed 's/.*://')
curl "http://localhost:${SANDBOX_PORT}/healthz"

Expected response:

{"status":"ok"}

2. Start n8n With Instance AI Configured

In a second terminal:

export N8N_INSTANCE_AI_MODEL=anthropic/claude-sonnet-4-5
export N8N_INSTANCE_AI_MODEL_API_KEY="$ANTHROPIC_API_KEY"

export N8N_INSTANCE_AI_SANDBOX_ENABLED=true

pnpm dev:ai

The instance-ai module is enabled by default. N8N_AI_ENABLED is not an Instance AI runtime gate.

The pnpm --filter n8n-containers services command writes N8N_INSTANCE_AI_SANDBOX_PROVIDER, N8N_SANDBOX_SERVICE_URL, and N8N_SANDBOX_SERVICE_API_KEY to packages/cli/bin/.env. If you are not using that generated .env file, export them manually:

export N8N_SANDBOX_PORT=$(docker port n8n-svc-sandbox-sandbox-api 8080/tcp | sed 's/.*://')
export N8N_INSTANCE_AI_SANDBOX_PROVIDER=n8n-sandbox
export N8N_SANDBOX_SERVICE_URL="http://localhost:${N8N_SANDBOX_PORT}"
export N8N_SANDBOX_SERVICE_API_KEY=n8n-sandbox-ci-key

For n8n running inside the same Docker network as the sandbox service, use the internal service URL instead:

N8N_SANDBOX_SERVICE_URL=http://sandbox-api:8080

3. Cleanup

pnpm --filter n8n-containers services:clean
docker network rm n8n-instance-ai-dev 2>/dev/null || true

Useful Commands

Run focused tests:

pnpm --filter @n8n/instance-ai test

Print agent prompts:

pnpm --filter @n8n/instance-ai prompts:print

Run evaluations:

pnpm --filter @n8n/instance-ai eval:instance-ai

More Documentation