Self-hosted agent architecture guide · Updated 2026-07-05

Self-hosted Agent Stack Architecture Guide: Runtime, Memory, Sandboxes, Gateways, Domain Workflows, Secrets, and Recovery

A practical architecture guide for combining self-hosted agent runtimes, persistent memory, tool execution, communication gateways, domain-specific workflows, scheduling, provider credentials, observability, backup, and recovery.

A self-hosted agent stack is rarely one product. The useful architecture separates the agent runtime from persistent memory, privileged tool execution, messaging gateways, domain workflows, scheduled jobs, provider credentials, and the operations needed to recover from bad runs or compromised integrations.

RepoDaily's current self-hosted set illustrates different layers rather than interchangeable competitors. DeerFlow is a broad long-horizon agent harness with subagents, memory, sandboxes, skills, and a gateway. Hermes Agent emphasizes an always-available personal agent with cross-session learning, reusable skills, multiple communication channels, cron, and deployment backends. Cognee is a dedicated memory control plane. Vibe-Trading is a domain-heavy research agent with backtests, tools, swarm workflows, persistent state, and financial controls. Daily Stock Analysis is a scheduled intelligence pipeline with dashboards and notifications.

RepoDaily verdict

Start by choosing the operating model, not the most feature-rich repository. Use a broad runtime such as DeerFlow when the product needs multi-step research, code execution, subagents, sandboxes, and a programmable gateway. Evaluate Hermes Agent when persistent personal context, skill learning, channels, cron, and flexible deployment are central. Use Cognee as a separable memory layer when multiple agents need durable, queryable, governed context. Treat Vibe-Trading and Daily Stock Analysis as domain workflow patterns rather than general runtimes. Keep provider credentials, memory stores, sandboxes, channels, and scheduled jobs as independently revocable boundaries.

Quick matrix

LayerPrimary jobRepoDaily exampleArchitecture question
Agent runtimePlan, call tools, delegate, manage long tasksDeerFlow / Hermes AgentDoes one runtime own the whole task lifecycle or only orchestration?
Subagents / swarmParallel or specialized task executionDeerFlow / Vibe-TradingHow are task scopes, budgets, failures, and outputs isolated?
Sandbox / executionRun code and tools away from sensitive host stateDeerFlow / Hermes backendsWhat filesystem, network, process, and secret access reaches the task?
MemoryPersist context and retrieve useful prior knowledgeCognee / Hermes Agent / DeerFlowIs memory per user, per agent, per project, or globally shared?
Gateway / channelsExpose agent sessions to UI, CLI, messaging, or API clientsDeerFlow gateway / Hermes gatewayHow are clients authenticated and sessions separated?
Domain workflowEncode research, finance, SEO, or other specialist processVibe-Trading / Daily Stock AnalysisWhich steps are deterministic and which depend on LLM judgment?
SchedulerRun recurring briefings, audits, or background tasksHermes cron / Daily Stock Analysis schedulesWhat happens after missed runs, retries, duplicates, and stale data?
NotificationsDeliver output to humans or downstream systemsHermes channels / Daily Stock Analysis deliveryCan notification credentials trigger actions or only deliver reports?
Provider layerLLM, search, market data, browser, embeddingsAll stacksAre keys scoped, rotated, budgeted, and isolated per environment?
OperationsHealth, logs, backups, upgrades, rollback, incident responseAll stacksCan the team stop jobs, revoke keys, restore state, and explain what happened?

Self-hosted agent stack readiness scorecard

Score the complete stack, not only the agent loop.

Control0 points1 point2 pointsOwner question
Runtime boundaryRuns with broad host accessSome isolationExplicit task runtime, filesystem, network, process and secret scopesWhat can one compromised task reach?
Memory isolationOne global storeManual namespacesPer-user/agent/project scopes with deletion, retention and backup policyCan one tenant retrieve another tenant's context?
Tool policyGeneric shell/browser/filesystemSome wrappersNarrow tools, approvals, budgets and audit eventsWhich actions can create irreversible side effects?
Provider secretsShared .env everywhereSeparate environmentsScoped identities, vault/secret boundary, rotation and budget controlsWhich service owns each credential?
Gateway securityOpen local/LAN APIAuthentication onlyAuth, session isolation, origin policy, rate limits and kill switchWho can start, resume, or steer a session?
Job reliabilityBest-effort scriptsBasic retriesIdempotency, retry policy, duplicate prevention, dead-letter/recovery pathWhat happens when a scheduled job fails halfway?
ObservabilityConsole logsCentral logsTask IDs, tool events, provider usage, errors, redaction and retentionCan we reconstruct one bad run end to end?
RecoveryReinstall is the planManual backupTested config/data backup, key rotation, rollback and clean-room restoreCan the service recover without trusting compromised state?

60-minute self-hosted agent stack architecture review

Use this before standardizing a runtime or granting persistent privileged access.

0–10 min: draw the stack

Map gateway, runtime, sandbox, tools, memory, scheduler, domain services, providers, databases and notification channels.

Success checkEvery component, credential flow and network boundary has an owner.

10–20 min: trace one task

Follow a representative request from client identity through planning, tool calls, memory reads/writes, artifacts, notification and logs.

Success checkThe team can explain where authority and data cross boundaries.

20–30 min: inspect secrets and tools

List every credential and privileged tool available to each service and execution context.

Success checkNo component has broad secrets or actions without a justified need.

30–40 min: attack isolation

Test cross-session memory access, sandbox escape assumptions, unauthorized gateway clients, wrong-scope tool calls and stale scheduled jobs.

Success checkThe stack fails closed before external side effects.

40–50 min: test operations

Stop a task, restart a service, retry a failed job, rotate one provider key, restore memory/config backup and inspect resulting logs.

Success checkCommon failures have deterministic operational paths.

50–60 min: choose the minimum stack

Remove unnecessary agents, gateways, memory systems, tools, providers and schedules from the first production design.

Success checkThe initial architecture is small enough for the team to own and recover.

Self-hosted agent architecture decision flow

  1. Start with the job: general research/coding agent, persistent personal agent, shared memory service, domain research workspace, or scheduled intelligence pipeline.
  2. Choose the runtime boundary. Decide whether the agent runs on the host, in containers, through SSH, in ephemeral sandboxes, or through serverless/remote execution backends.
  3. Separate privileged tools from conversational state. List shell, filesystem, browser, network, database, container, finance, and notification actions, then narrow scopes and approval requirements.
  4. Design memory as its own data system. Define source ingestion, namespaces, retention, deletion, backup, model/embedding dependencies, tenant separation, and how retrieval evidence is inspected.
  5. Design the gateway separately from the runtime. Authenticate clients, isolate sessions, validate browser origins where relevant, limit message size/rate, and provide an emergency stop path.
  6. Classify domain workflows into deterministic stages and LLM judgment stages. Preserve source data, intermediate artifacts, prompts/config, tool results, and final outputs so recurring reports can be audited.
  7. Assign provider identities by service and environment. Do not let every component inherit every LLM, search, browser, market-data, messaging, or database credential.
  8. Define lifecycle behavior: startup dependencies, health checks, scheduled runs, retry policy, duplicate prevention, stale task cleanup, upgrade order, migration tests, and graceful shutdown.
  9. Prove recovery before adding more autonomy: revoke a provider key, stop a runaway task, restore memory from backup, rebuild the runtime from clean state, and verify that logs are useful without exposing secrets.

Scenario table

ScenarioRecommended starting architectureWhyMain risk
Team research and coding agentDeerFlow-style runtime + isolated sandbox + scoped memory + authenticated gatewayBroad runtime capabilities fit long-horizon research and code tasksSandbox, shell, file-write and provider-key exposure
Persistent personal assistantHermes-style always-on agent + personal memory + channels + cron + remote execution backendCross-session learning and messaging presence are core requirementsChannel identity, autonomous skill growth and long-lived credentials
Shared memory for multiple agentsAgent runtimes + separate Cognee-style memory control planeMemory lifecycle and tenant boundaries can evolve independently from runtimesNamespace leakage, retention mistakes and model/embedding dependency drift
Quant research workspaceVibe-Trading-style domain runtime + market data + backtest + bounded connectors + audit ledgerSpecialized tools and deterministic evaluation matter more than generic chatFinancial loss, data quality, lookahead leakage and connector permissions
Daily market intelligence briefingDaily Stock Analysis-style scheduled ETL/research pipeline + dashboard + notificationsRecurring report generation is a pipeline problem more than a general agent problemData drift, duplicated jobs, stale reports and over-trusting LLM conclusions
Small internal automationOne narrow agent service + minimal memory + explicit tools + schedulerAvoid unnecessary multi-agent and gateway complexityOverbuilding before ownership and recovery are clear
Multi-tenant SaaS agentGateway + tenant-isolated runtime jobs + isolated memory namespaces + centralized policy/auditUser separation must be designed across every layerCross-tenant data/tool leakage and shared-secret blast radius
High-risk privileged automationHuman-approved broker service around agent planning + disposable execution + immutable logsSeparate planning from irreversible executionAgent prompt/tool compromise causing host or external side effects

Architecture risks to review

Monolithic agent container

Putting runtime, browser, shell, memory database, provider keys, messaging credentials, and host mounts into one container creates a large compromise radius.

Global memory

A shared knowledge store without explicit user, agent, project, and retention boundaries can leak sensitive context across tasks or tenants.

Tool capability inflation

General shell, filesystem, browser, arbitrary fetch, database, broker, and container controls are convenient but turn prompt compromise into operational compromise.

Gateway equals runtime

A public or LAN-facing gateway should not automatically inherit all runtime privileges. Treat session admission and privileged execution as separate decisions.

Autonomous skill accumulation

Self-created or imported skills can become persistent executable policy. Track provenance, review changes, constrain tools, and support disable/rollback.

Scheduler without idempotency

Recurring agent jobs can duplicate notifications, reports, trades, writes, or API costs when retries and overlap are not designed.

Provider-key sprawl

A single .env shared across runtime, memory, search, browser, messaging, and domain connectors makes one component compromise affect the whole stack.

No clean-room recovery

Restoring the same mutable state after compromise can reintroduce malicious skills, poisoned memory, unsafe config, or leaked credentials.

Reference architecture patterns

Pattern A: General agent workspace

Authenticated gateway → agent runtime → per-task sandbox → narrow tools → scoped memory. Keep provider keys and host mounts outside the sandbox by default.

Pattern B: Personal always-on agent

Messaging gateway → personal session identity → agent runtime → user-scoped memory → cron jobs → remote/ephemeral execution backend. Separate notification credentials from privileged tool credentials.

Pattern C: Domain intelligence pipeline

Scheduler/event → deterministic data collection → agent analysis → evidence/artifact store → review gate → dashboard/notification. Preserve raw inputs and intermediate outputs for audit.

Memory as a service

Expose remember/recall/forget/improve-style operations or another narrow memory contract so runtime replacement does not require migrating every agent integration at once.

Brokered privileged tools

Place shell, browser, container, finance, or production actions behind a narrow broker that validates scope, identity, budget, approvals, and audit metadata.

Clean-room recovery bundle

Back up reviewed configuration, memory exports, domain data, schemas and audit logs separately from ephemeral runtime state, caches and generated skills awaiting review.

FAQ

Short answers for teams designing self-hosted agent infrastructure.

Do I need a multi-agent runtime?

Usually not for the first deployment. Use subagents or swarms when tasks are genuinely parallel or specialized and you can observe budgets, failures and output quality independently.

Should memory live inside the agent runtime?

Small personal deployments can keep memory integrated. Teams with multiple agents, tenants, retention requirements or audit needs should evaluate a separable memory layer so lifecycle and isolation can be managed independently.

Is Docker enough sandboxing for agent tools?

Containerization helps but the real answer depends on mounts, capabilities, network access, runtime sockets, secrets and host integration. Review the actual execution boundary and use disposable or remote environments for higher-risk tasks.

What is the difference between an agent runtime and a domain workflow?

A runtime provides general planning, tools, memory and execution mechanics. A domain workflow encodes specialized data sources, deterministic stages, evaluation rules, reports and controls for a specific job such as finance research.

What should be backed up?

Back up reviewed configuration, memory or knowledge exports, schemas, domain datasets, approved skills and audit evidence. Treat caches, temporary sandboxes and unreviewed generated state as disposable unless the product explicitly depends on them.

What is the first production control to add?

A reliable stop path. The team should be able to halt scheduled jobs and active tasks, revoke provider credentials and disable privileged tools before increasing autonomy.

Related radar

Self-hosted Apps & Local Infrastructure Radar

Related RepoDaily briefs

Sources

  1. DeerFlow official repository
  2. DeerFlow backend architecture
  3. Hermes Agent official repository
  4. Hermes Agent configuration docs
  5. Cognee official repository
  6. Cognee core concepts
  7. Cognee integrations
  8. Vibe-Trading official repository
  9. Daily Stock Analysis official English README
  10. RepoDaily Local Service Security Checklist

Feedback

Did this page help you make a decision?

Anonymous feedback helps RepoDaily improve what is actually useful.

Report outdated or missing evidence