How to Quickly Integrate and Manage Multiple AI Agents Without Rewriting Code
I’m Denis Shokhirev, Enterprise AI architect based in Erlangen, Germany. My stack is Claude, Supabase, n8n, Doppler, and self-hosted Postgres. In the past 6 months, I’ve shipped 14 production AI agents for DACH B2B clients in logistics, fintech, and industrial automation. The most common real-world ask: “Add a new agent, but don’t break the old flow.” Architecting for multi-agent management—without endless refactoring—became a non-negotiable design priority. The Real Problem: Stability, Securi
I’m Denis Shokhirev, Enterprise AI architect based in Erlangen, Germany. My stack is Claude, Supabase, n8n, Doppler, and self-hosted Postgres. In the past 6 months, I’ve shipped 14 production AI agents for DACH B2B clients in logistics, fintech, and industrial automation. The most common real-world ask: “Add a new agent, but don’t break the old flow.” Architecting for multi-agent management—without endless refactoring—became a non-negotiable design priority.
The Real Problem: Stability, Security, Speed
Shipping AI agents in regulated B2B environments is never about a flashy demo. It’s about integrating new agents quickly, without breaking the stable core or introducing security vulnerabilities. Rewriting the core application for every new agent is a recipe for technical debt and missed deadlines, especially when compliance (think finance or logistics) is on the line.
Reference Pattern: Plug New Agents Without Core Changes
1. Request Routing via API Gateway (n8n)
My first three agents were hardcoded into REST endpoints—after the third, I switched to using n8n as an orchestration layer. Incoming requests hit n8n, which routes them to the right agent based on configurable rules (parameters, headers, or payload keys). This keeps agent logic out of the app core and makes switching or adding agents trivial.
// Agent selection in n8n workflow
{
"nodes": [
{
"parameters": {
"functionCode": "return items.map(item => { item.agent = item.json.route === 'finance' ? 'claude_fin' : 'claude_log'; return item; });"
},
"name": "Routing",
"type": "n8n-nodes-base.function",
"typeVersion": 1
}
]
}
All logic is config-driven in n8n. No code changes in the main app to onboard new agents.
2. State and Logging with Supabase/Postgres
Each agent’s activity, status, and task logs are stored in Supabase (Postgres under the hood). This means onboarding a new agent is just a schema tweak or new table, not a migration-heavy code rewrite. Real example: I added a new agent for a logistics client by inserting a single row describing its config and endpoint—no downtime, no code merge.
-- Agent activity logging in Postgres
CREATE TABLE agent_logs (
id SERIAL PRIMARY KEY,
agent_name TEXT NOT NULL,
request_payload JSONB,
response_payload JSONB,
created_at TIMESTAMP DEFAULT NOW()
);
This makes it easy to audit, debug, and roll back agents independently.
3. Secrets Management with Doppler
Each agent comes with its own API keys, tokens, and sometimes encryption secrets. Never store these in code or .env files. I use Doppler for centralized secret management, which n8n can access on-demand per agent. This reduces the risk of credential leaks when adding new agents.
doppler secrets set CLAUDE_API_KEY=sk-xxxxxx
doppler secrets set LOGISTICS_AGENT_TOKEN=tok-yyyyy
n8n pulls the relevant secret for each agent at runtime—no more hardcoded variables.
Security: What Actually Catches Issues in Production
Across 14 agents shipped, I’ve personally caught SQL injection patterns in LLM-generated code in 4 separate deployments—especially when users prompt for custom SQL. To reduce risk, I always run:
- semgrep for static analysis (CWE/OWASP patterns);
- bandit for Python-specific issues;
- gitleaks to catch accidental secret commits.
semgrep --config=owasp-top-ten .
bandit -r ./src
gitleaks detect --source .
This pipeline catches most issues before agents hit production. For reference, Stanford’s 2024 CodeML study (arxiv.org/abs/2402.00003) found 38% of LLM-generated Python had CWE-89 SQL injection patterns—manual review is not enough.
Scaling: Add Agents in Days, Not Weeks
1. New Agent = New Route + Config
Onboarding a new agent means adding a route in n8n, an entry in Supabase, and secrets in Doppler. No main app code touch. This flow let me launch a production agent for an industrial automation client in 36 hours—no core repo changes, no regression risk.
2. Validation and Testing
I use automated checks in Postgres (log/state sanity), plus manual workflow review in n8n before go-live. This minimizes the risk of silent failures or security regressions.
| Task | Solution | Tool |
|---|---|---|
| Request Routing | Configurable workflows | n8n |
| Logging/State Storage | Separate table per agent | Supabase/Postgres |
| Secret Management | Centralized vault | Doppler |
| Static Analysis | CWE/OWASP scans | semgrep, bandit |
FAQ
How do I make sure a new agent doesn’t break the existing service?
All integration happens via n8n and isolated tables in Supabase. Any agent failure is sandboxed—rollback is fast and safe.
Does this pattern work for legacy monoliths?
I’ve migrated legacy projects (5+ years old) to this pattern: move agent logic out to n8n, log state in new tables, and keep core business logic untouched. It’s easier than shoehorning new agents into monolithic code.
What’s the biggest security risk when adding agents?
SQL injection and secrets leaks. Use static analysis tools (semgrep, bandit, gitleaks) and Doppler for secrets—don’t skip these steps.
How do you handle agent versioning?
I log agent version and release date in Supabase. n8n routes can switch to new versions with zero code change in the main app.
Can agent testing be automated?
Yes—use n8n test workflows and Postgres queries to validate agent state, plus manual workflow review for critical deployments.
At which stage does integrating a new AI agent usually break for you—routing, state management, or security checks? I run a free 30-min stack audit for DACH founders building AI in regulated industries. DM me on LinkedIn or write to @ger_dennis_ai.
Turn your process into an AI system
Fixed price. Production quality. DACH B2B focus.