Skip to content
AI Bot Architecture: Least Privilege, Composition, and Separation of Concerns

AI Bot Architecture: Least Privilege, Composition, and Separation of Concerns

This article applies five software engineering principles—least privilege, composition over inheritance, separation of concerns, single responsibility, and dependency inversion—to AI Bot design, using Meta Muse and Grok Bot as case studies to demonstrate how proper permission boundaries, component composition, and architectural separation enable reliable production-grade agents.

AI Engineer Programming
AI Engineer Programming
AI Engineer Programming

Introduction: Bots Are Becoming Independent Software Systems

From OpenClaw to recent AI Bot products, the design focus has shifted from what a model can answer to what responsibilities a Bot can sustain long-term. Two products illustrate this shift.

Meta Muse

Released by Meta in September 2026, Muse understands user needs, formulates plans, operates browsers, handles email, and completes shopping. Its security design includes:

Each user gets an independent Muse Secure VM.

Muse and Sentinel are separated at the system layer.

Sentinel approves external network access.

Users control application connections and read/send permissions separately.

Sensitive operations require user confirmation.

Users can view operation audit logs.

Grok Bot

Released by xAI in 2026, Grok Bot emphasizes continuously running agents:

Each Bot has independent identity, memory, tools, and runtime environment.

Routines execute scheduled or event-triggered tasks.

Multiple Bots can collaborate.

Bots can use browser, filesystem, terminal, and external applications.

Users can intervene during task execution.

High-risk operations are controlled via approval mechanisms.

Muse emphasizes user-level isolation, independent secure execution environments, and Sentinel approval. Grok Bot explicitly states that multiple Bots of the same user share a cloud computer, so files, browser sessions, and CLI credentials may be accessed by different Bots. Creating multiple Bots does not automatically achieve permission isolation.

Both products reveal a critical issue: once Bots gain execution capabilities, we cannot design them with only prompt engineering thinking; we must return to software engineering fundamentals. This article assumes that traditional programming and AI coding still fall within software engineering (demos excluded) and examines five principles:

Least Privilege

Composition Over Inheritance

Separation of Concerns

Single Responsibility Principle

Dependency Inversion Principle

These principles are not new to the AI era, but when probabilistic decision-making models enter software systems, they must be re-grounded.

Least Privilege: Bots Should Not Have Capabilities Beyond the Task

Consider a common demo scenario: "Organize last week's emails by importance and generate a summary." If we grant the Gmail connector's full permission to the Bot, it gains: read, search, delete, send, create rules, modify account settings. Functionally this works, but from a security perspective, the task needs only read and search. The mismatch between required and granted permissions is exactly what least privilege addresses.

2.1 Permissions Should Follow Tasks, Not Bot Identity

Traditional software uses RBAC. Example roles:

Email Reader : Read email

Email Manager : Read, send, delete email

System Admin : Manage accounts and system config

But an Agent may perform different tasks over time. Assigning a static permission set to the Bot identity leads to over-privilege. Better design: Identity determines the principal, task determines permission scope, resource and operation determine the final authorization decision; any one failing denies authorization.

Example task-specific permissions:

Email Organization : Allow search, read; deny send, delete.

Email Drafting : Allow search, read, create draft; deny send.

Email Sending : Allow read, send specified email; deny bulk send, delete.

Spam Cleanup : Allow query, mark, move; deny permanent delete.

Permissions must be re-checked at each external resource access, not just at task start. If a user revokes email access mid-execution, subsequent tool calls must be re-authorized.

2.2 Don't Put Permission Control in the Prompt

Putting permissions in system prompt constrains model behavior, not system permissions
Putting permissions in system prompt constrains model behavior, not system permissions

Figure 1: Putting permissions in the system prompt constrains model behavior, not system permissions.

This only constrains model behavior, not a true security boundary. Prompt injection or model misunderstanding can still cause unauthorized tool calls. Correct approach: place authorization outside the model.

Authorization check outside model: identity, task, resource, operation — any mismatch denies
Authorization check outside model: identity, task, resource, operation — any mismatch denies

Figure 2: Authorization check outside model: identity, task, resource, operation — any mismatch denies.

The model proposes operations; an independent policy engine verifies:

Who initiated the task?

What is the current task?

What is the target resource?

Does the current identity have the required permission?

Has the authorization expired or been revoked?

Authorization must be checked at every external resource access by a trusted execution boundary, not just once at the Agent Gateway.

2.3 Sub-Agents Cannot Inherit All Parent Agent Permissions

Sub-agent permissions shrink layer by layer, not inheriting parent's full scope
Sub-agent permissions shrink layer by layer, not inheriting parent's full scope

Figure 3: Sub-agent permissions shrink layer by layer, not inheriting parent's full scope.

In a multi-Bot system, a main Bot handling enterprise complaints might access customer info, orders, financial data, and complaint history. Delegation is not copying; each delegation should narrow permissions. Correct approach: permissions shrink layer by layer.

Main Bot : Access summary info needed for complaint task; allowed operation: task coordination.

Legal Bot : Access contracts, dispute records; allowed operation: legal risk analysis.

Finance Bot : Access orders, refund records; allowed operation: refund amount calculation.

Support Bot : Access customer communication records; allowed operation: generate reply drafts.

Sub-agent permissions are constrained by delegated authorization and cannot expand the original scope via task delegation. This involves Agent identity, permission delegation, and scope attenuation.

Bot permissions should be task-level, resource-level, operation-level, and time-level, not simply bound to a Bot name.

Composition Over Inheritance: Don't Design Bots as Ever-Growing Inheritance Trees

Suppose we need Email Bot, Calendar Bot, Finance Bot, Legal Bot, Dev Bot, Support Bot. A naive approach creates a BaseAgent class with plan, execute, remember, use_tools methods, then subclasses for each Bot. Initially fine, but as business grows, problems emerge.

3.1 Inheritance Binds Unrelated Capabilities

Email Bot needs long-term memory of email history. Finance Bot accesses financial data but shouldn't see all personal email info. Legal Bot needs contracts, litigation materials, legal knowledge base. They don't need the same memory structure, permission system, tool set, execution environment, trigger mechanism, or lifecycle. Stuffing all capabilities into BaseAgent leads to a bloated class with methods like read_email, query_finance, search_legal_docs, execute_shell, send_message. Subclasses override or use config switches to enable/disable capabilities. This is not reuse; it forces different business changes to be coupled together. A change in one feature may affect other Bots.

3.2 Build Bots with Composition

Treat a Bot as a set of composable components.

Nine component types: identity, role, context, memory, tool registry, policy, runtime, trigger, state
Nine component types: identity, role, context, memory, tool registry, policy, runtime, trigger, state

Figure 4: Nine component types: identity, role, context, memory, tool registry, policy, runtime, trigger, state.

Different Bots compose these components. For comparison, only business-relevant components are shown; Trigger and State Store are provided by the runtime.

Three Bots share component types: context, memory, tools, policy, runtime, but implementations differ
Three Bots share component types: context, memory, tools, policy, runtime, but implementations differ

Figure 5: Three Bots share component types: context, memory, tools, policy, runtime, but implementations differ.

They can share common execution engine, logging, tool calling interface, and state management, but need not share all business capabilities. Sharing implementation does not equal sharing permissions, nor sharing business state.

3.3 Composition Doesn't Mean Unconstrained Assembly

Single configuration containing email, finance, admin, shell, and production database tools
Single configuration containing email, finance, admin, shell, and production database tools

Figure 6: Single configuration containing email, finance, admin, shell, and production database tools.

Unconstrained composition turns a bloated inheritance hierarchy into a bloated component configuration. Composition must combine with capability constraints. Recommended approach:

Define component contracts via explicit interfaces.

Manage available components via a registry.

Restrict component usage scope via Policy Engine.

Provide component instances via dependency injection.

Determine available capabilities via task context.

Prevent unauthorized component calls via runtime validation.

Composition's value is not more freedom, but independent evolution while controlling inter-component dependencies.

Separation of Concerns: Model Thinks, System Controls

In traditional software, we separate business logic, data access, permission checks, transaction management, and logging because they change for different reasons. Agent systems should follow the same principle.

4.1 Don't Let the Model Handle Both Decisions and Authorization

Model solves: user intent, task decomposition, next step, tool selection, result satisfaction. System solves: user permission, agent permission, resource access allowance, human approval need, failure recovery, execution tracing.

Mixing these is a common error.

Model both decomposes tasks and judges permissions, no independent verification fallback
Model both decomposes tasks and judges permissions, no independent verification fallback

Figure 7: Model both decomposes tasks and judges permissions, no independent verification fallback.

This tries to replace system control with model self-constraint. But the model may misunderstand authorization or be influenced by malicious instructions in external data. Better architecture:

Policy engine routes: allowed operations go direct to tools, approval-required go to human review
Policy engine routes: allowed operations go direct to tools, approval-required go to human review

Figure 8: Policy engine routes: allowed operations go direct to tools, approval-required go to human review.

Agent proposes execution; independent policy engine makes authorization decisions. Policy judgment and model inference must be architecturally separated; cannot rely on model to judge permission boundaries.

4.2 Separate Task Planning from Task Execution

User request: "Analyze last month's sales data, find products with largest decline, give adjustment recommendations." Steps: query sales data, clean data, calculate product sales changes, identify declining products, analyze causes, generate recommendations.

If planning, execution, and state management are all in one model loop, problems arise: model may skip steps, repeat completed steps, continue with incomplete data after tool failure, continue old plan after user changes goal, not know where to resume after interruption.

Split into three parts:

Planner : generates plan.

Task Manager : advances task state.

Executor : executes concrete operations.

Planning, advancing, execution split into three stages; task completion judged by system
Planning, advancing, execution split into three stages; task completion judged by system

Figure 9: Planning, advancing, execution split into three stages; task completion judged by system.

Model can propose plans and suggest re-planning, but cannot decide a task is complete. Completion depends on actual execution results, business rules, and verification results.

4.3 Separate Memory from Business State

Many Bot products emphasize Memory. From software engineering view, memory is not a single dumping ground. At least three types:

User Memory : preferences, long-term habits; lifecycle: long-term.

Task State : current step, execution results, failure records; lifecycle: task lifetime.

Business Data : orders, emails, contracts, financial records; lifecycle: managed by business systems.

User says: "Prefer Excel format for future reports." → user preference → long-term memory. "Current refund task completed amount calculation, awaiting approval." → workflow state → reliable state store. Refund order itself → business system record. Model context saying refund succeeded does not mean business system completed it. Memory provides context, state tracks execution progress, business system stores real results. These three must have clear data boundaries.

Single Responsibility: A Bot Should Not Take All Responsibilities for Convenience

Single Responsibility Principle is often misunderstood as one class one method. It means a module should change for a single reason. Applies to Bots. Enterprise customer service Bot handling: understand issue, search knowledge base, query orders, calculate refund, approve refund, execute refund, send notification, modify customer profile. This puts different risk-level responsibilities in one executor. Search knowledge base (info retrieval) vs execute refund (real money movement) are different responsibilities. After splitting:

Support Bot only coordinates; refund flow split into calculation, approval, execution
Support Bot only coordinates; refund flow split into calculation, approval, execution

Figure 10: Support Bot only coordinates; refund flow split into calculation, approval, execution.

Refund calculation, approval, execution are separate responsibilities. Can be different modules or different identities. High-risk business should enforce separation of duties:

Agent A calculates refund amount.

Approval system verifies refund conditions.

Human with approval authority confirms.

Agent B or independent execution service submits refund.

Payment system returns final result.

Even if Agent A is manipulated, it cannot complete the entire refund chain. More reliable than repeated prompt warnings.

Dependency Inversion: Bot Should Not Depend on a Specific Platform

If you're an application developer, not a model vendor, avoid binding business logic to a specific service. Example: Email Bot using Gmail SDK directly couples business code to Gmail. Adding QQ Mail or enterprise mail requires modifying business code. Better: define interface.

class EmailProvider:
    def search(self, query):
        raise NotImplementedError
    def read(self, email_id):
        raise NotImplementedError
    def create_draft(self, content):
        raise NotImplementedError

Concrete platforms implement the interface:

class GmailProvider(EmailProvider):
    pass
class QQProvider(EmailProvider):
    pass

Agent depends only on EmailProvider, not on underlying mail service. But interface abstraction cannot hide permission differences. Gmail and QQ may have different permission models and supported operations. Cannot assume identical security capabilities just because they implement the same interface. Need capability declarations and authorization checks.

Agent depends on capability interface; adapters connect Gmail, Outlook, enterprise mail
Agent depends on capability interface; adapters connect Gmail, Outlook, enterprise mail

Figure 11: Agent depends on capability interface; adapters connect Gmail, Outlook, enterprise mail.

Authorization checks should sit on the concrete operation execution path. This separates business logic, third-party service adapters, and permission management. Foundation for future Bot platforms to avoid lock-in to a specific model, MCP Server, or SaaS platform.

Combined Principles: A Truly Maintainable Bot Architecture

The principles are interrelated:

Least privilege solves capability boundaries.

Composition over inheritance solves module organization.

Separation of concerns solves coupling between responsibilities.

Single responsibility solves mixed change reasons.

Dependency inversion solves coupling between business logic and concrete implementations.

Together they form this architecture:

Full request path: identity, task, action, authorization, execution to capability layer, with independent supporting capabilities at bottom
Full request path: identity, task, action, authorization, execution to capability layer, with independent supporting capabilities at bottom

Figure 12: Full request path: identity, task, action, authorization, execution to capability layer, with independent supporting capabilities at bottom.

Policy Engine is not a simple text check after model output, but a mandatory control point on the tool execution path. Audit cannot rely on Agent deciding whether to log; critical execution events must be independently recorded by execution infrastructure.

7.1 Runtime Considerations for Production

Production-ready applications face scaling challenges: concurrency, service scaling, rate limiting, recovery. Agent-specific concerns:

Permission revocation : After user revokes a connector, already-running tasks must not continue using previously granted permissions.

Execution idempotency : Bots may retry due to timeout, crash, or duplicate message delivery. Operations like send email, refund, place order need idempotency keys and business-side deduplication.

State recovery : Task crashes at step 3; recovery cannot simply re-run all steps. Must determine which steps truly completed based on persisted state and external business results.

Resource isolation : Files, credentials, browser sessions, task states across different users, tenants, Bots must be isolated by explicit security boundaries.

Operation traceability : Must answer seven questions (who, what, when, where, why, how, result) — cannot rely only on chat logs.

Operation traceability: seven questions, records must have answers
Operation traceability: seven questions, records must have answers

Figure 13: Operation traceability: seven questions, records must have answers.

Special attention to compliance requirements and limitations!

Muse and Grok Bot: Lessons Are in Design Trade-offs, Not Features

Applying the principles to both products reveals valuable design differences.

Execution Environment : Meta Muse — User-independent Muse Secure VM; Grok Bot — Same user's Bots share cloud computer.

Security Isolation : Meta Muse — Independent VM and Sentinel; Grok Bot — Cloud computer, network policies, execution controls.

Permission Management : Meta Muse — User controls app and operation permissions; Grok Bot — Connector permissions, Auto Review, team policies.

Sensitive Operations : Meta Muse — Require user confirmation; Grok Bot — Configurable Ask-first approval rules.

Multi-Bot : Meta Muse — Public product focuses on personal assistant; Grok Bot — Explicitly supports multiple Bot collaboration.

Continuous Operation : Meta Muse — Can continue working after user leaves app; Grok Bot — Supports Routines and continuous tasks.

Memory : Meta Muse — Remembers user preferences and important info; Grok Bot — Bots have persistent memory and role context.

Three engineering issues to note:

Creating multiple Bots ≠ achieving security isolation. Grok Bot's security docs state same-user Bots share a cloud computer, so different Bots cannot be treated as security boundaries. Role division and security isolation are different.

Security checks cannot rely solely on the model. Muse uses independent Sentinel for external access control; Grok Bot exposes Auto Review, network policies, connector authorization. Implementations differ but share the principle: model's execution intent and system's execution authorization must be separate.

Continuous operation changes system security requirements. A Q&A Bot's error affects only current interaction. A continuously executing Bot may send messages, modify files, operate external systems after user leaves. Long-running agents need explicit authorization expiry, stop mechanisms, state management, and audit capabilities.

Conclusion: AI Era Didn't Invalidate Software Engineering Principles; It Amplified Their Importance

The biggest mistake in Bot design today is repackaging already-solved software engineering problems as AI problems.

Permission insufficient? Add prompt. Too many tools? Add an Agent. Task complex? Add sub-agents. Context insufficient? Add memory. Execution unstable? Add retries.

These sometimes improve experience but don't fundamentally solve system design issues. The real questions are:

Six probing questions pointing to system boundaries
Six probing questions pointing to system boundaries

Figure 14: Six probing questions pointing to system boundaries.

These questions belong to software architecture, system security, and engineering governance, not model capabilities.

Least Privilege: Bot gets only capabilities needed for current task, not all it might theoretically use.

Composition Over Inheritance: Bot composed of identity, context, memory, tools, policy, runtime; not dependent on ever-growing inheritance hierarchy.

Separation of Concerns: Model proposes decisions; system handles authorization, execution, verification, recording.

Single Responsibility: Different risk levels, business rules, lifecycles have clear boundaries.

Dependency Inversion: Bot business logic depends on stable capability interfaces, not bound to a specific model, tool, or external platform.

A good Bot is not about having the most tools, most permissions, or most complex Agent collaboration, but about reliably fulfilling its responsibilities within explicit boundaries. Crossing from a conversational AI program to a long-running software system requires crossing this threshold.

Finally, where to draw the line between Bot permission inheritance, capability composition, and context sharing is where design flaws most easily appear when moving from demo to production.

References

https://www.nist.gov/blogs/cybersecurity-insights/design-tenets-agent-identity-management-systems

Official Bot websites

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

software engineeringPermission ManagementAgent ArchitectureAI BotComposition Over InheritanceSeparation of ConcernsLeast PrivilegeAgent Security
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.