AI Agent Development: Architecture, Security, Cost Factors, and Pilot Scope

Gartner expects over 40% of agentic AI projects to be cancelled by the end of 2027, citing escalating costs, unclear business value, and inadequate risk controls. Weak risk controls often start with a setup like this one.
An operations team connects an AI agent to email, a ticketing system, and a customer database. The agent can call each tool, but it borrows a developer’s broad credentials. No rule states which records it may update or which messages require approval. The model is capable. The action space is uncontrolled.
AI agent development is software engineering around a model that can select steps and use tools. The product includes workflow, orchestration, identity, permissions, state, evaluation, monitoring, and human control. Reliability depends on those components more than on a single model response.
The safest starting point is one bounded workflow with recoverable actions. Define the permitted action space before increasing autonomy. This guide follows one example throughout: a ticket-triage agent that reads new support tickets, drafts a summary and reply, and proposes updates to the customer record.
An agent acts inside a controlled system
- Trigger and user
- Orchestrator
- Model and retrieval
- Policy and tools
- Audit and approval
Permission checks, validation and logs sit outside the model and govern every consequential action.
What AI agent development includes
An AI agent receives a trigger or goal, interprets context, selects tools, maintains task state, and produces an answer or action. The agent may use a large language model for planning and judgement, but deterministic software should control identity, policy, validation, and side effects.
An agent differs from a chatbot because it can act across systems, not just respond in a conversation. It differs from deterministic automation because the model may choose a path at runtime. Many useful products combine both: the model classifies or proposes, and fixed workflow code validates and executes.
Core components include
- A defined workflow, trigger, and completion condition.
- An orchestration layer that manages steps, timeouts, and state.
- A model and optional retrieval layer for task context.
- Tools with typed inputs, validated outputs, and scoped credentials.
- A policy layer for permissions, approvals, and blocked actions.
- State or memory with retention and access rules.
- Evaluation, traces, metrics, and an audit log.
- Human review, exception handling, and rollback.
EspioLabs provides AI software development and R&D for teams moving from workflow definition through pilot and controlled production.
Start with a bounded workflow.
Do not begin with a broad goal such as “manage customer operations.” Choose a repetitive task with clear inputs, measurable outcomes, controlled systems, and recoverable actions. Examples include drafting a ticket summary, proposing a knowledge article, reconciling a known set of fields, or preparing a change request for approval.
Write the workflow as an operating contract:
| Field | Definition | Ticket-triage example |
|---|---|---|
| Trigger | Event or user request that starts the task | A new ticket arrives in the support queue. |
| Inputs | Approved data and context are available at the start. | Ticket text, customer tier, and linked knowledge articles |
| Tools | Exact interfaces the agent may call | Ticket read, knowledge search, email draft, customer-record draft update |
| Permissions | Read, propose, create, update, or delete rights per tool. | Read and propose only during the pilot. |
| Approval | Actions that require a person and the required role | A support lead approves every outbound reply and record change |
| Output | Structured result and destination | Category, priority, summary, and draft reply attached to the ticket |
| Failure path | Retry, fallback, escalation, and stop conditions | Low confidence or missing context routes the ticket to the manual queue. |
| Success measure | Task completion, quality, time, cost, and user outcome | Routing accuracy, reviewer edit rate, handling time, and cost per ticket |
Select a workflow where a failed action can be reversed or contained. An agent that drafts a refund recommendation is easier to pilot than one that issues refunds across every account. Staged autonomy makes the same product useful before write access is granted.
The AI proof of concept vs. MVP guide can help match the pilot scope to the uncertainty being tested.
Reference architecture for an AI agent
The interface receives a user request or system event and authenticates the initiating identity. The orchestrator creates a task, loads approved context, and calls the model. The model can propose a tool, but a policy layer checks whether that tool, action, and resource are permitted for the agent and user.
Reference architecture: an internal policy assistant
Security boundaries live outside the model. Every request leaves a trace with versions, sources, latency and cost.
- EmployeeAsks a policy question
- App gatewayAuthentication, quotas, request ID
- OrchestratorTask policy, context assembly, route choice
- Retrieval serviceVersioned index, document permissions, freshnessModel gatewayApproved versions, timeouts, token limits, cost tags
- Validation and policy checksCitations present, structure valid, risk category checked
- Cited answerSources and effective dates shown
- Constrained fallbackSearch results or static notice
- Human service queueRequest, sources, risk flag and reason
Tool adapters validate arguments before calling downstream systems. Responses are treated as untrusted data and parsed into typed structures. State stores the minimum context needed for the task. Every step records the model, prompt, tool, arguments, result, policy decision, latency, and cost.
Consequential actions enter an approval queue. The reviewer sees the proposed action, source evidence, and expected effect. After approval, the deterministic code executes the change and records the outcome. A recovery service handles timeouts, duplicate prevention, and rollback.
This separation matters. A system prompt is not an access-control boundary. A model instruction such as “never delete records” cannot replace a tool interface that lacks delete permission.
Retrieval quality depends on the knowledge base behind it. If articles lack owners, current versions, or access labels, a data modernization strategy for AI should fix those gaps before the agent reads them.
Microsoft’s AI agent orchestration patterns call for least privilege, user-identity handling, security trimming, and audit trails across agent patterns. The architectural principle applies across cloud platforms.
Identity, permissions, and tool access
Give the agent its own workload identity and scope it to one workflow. Do not reuse a developer account, shared API key, or full user session. If the agent acts for a person, preserve that user’s resource permissions and record the delegation.
Apply least privilege at the action level. A tool for customer records may expose separate read, draft-update, and approved-update operations. The pilot may receive only read and draft permissions. Production write access can be added after evaluation and operating evidence.
Use short-lived credentials where the platform supports them. Store secrets outside prompts and in a model-visible state. Filter retrieval results according to the initiating user’s access before the model receives them.
NIST’s Zero Trust Architecture rejects implicit trust based on network location and calls for per-session access decisions. Agent systems benefit from the same resource-centred approach: authenticate the identity, authorize the requested action, and verify each call.
AI agent security threats and controls
OWASP’s Top 10 for Agentic Applications for 2026 groups agentic risks into ten categories, from agent goal hijack (ASI01) to rogue agents (ASI10).
Translate the taxonomy into controls tied to the workflow. The examples below use the ticket-triage agent.
| OWASP category | Ticket-triage example | Practical control |
|---|---|---|
| ASI01 Agent goal hijack | A ticket hides instructions to email the full customer history. | Separate data from instructions, restrict tools, and test indirect injection. |
| ASI02 Tool misuse | The agent uses a bulk-update function to close related tickets. | Typed tools, allowlisted parameters, rate limits, and approval |
| ASI03 Identity and privilege abuse | A shared credential exposes records from other regions. | Dedicated identity, delegated access, and per-resource authorization |
| ASI04 Agentic supply chain vulnerabilities | A connector or model update changes tool behaviour | Approved registry, version pinning, review, and software inventory |
| ASI05 Unexpected code execution | A generated script reaches a runtime. | Sandboxed execution, no network by default and resource limits |
| ASI06 Memory and context poisoning | A malicious ticket stores false guidance used in later tasks. | Scoped memory, provenance, review, and expiration |
| ASI07 Insecure inter-agent communication | A routing agent accepts unauthenticated messages from another agent. | Authenticate and validate every agent message. |
| ASI08 Cascading failures | One wrong category triggers escalations across several systems. | Transaction boundaries, idempotency, circuit breakers, and rollback |
| ASI09 Human-agent trust exploitation | A confident draft persuades a reviewer to approve an incorrect credit. | Show evidence and effect, require a reason for high-consequence approvals, and provide sample reviews. |
| ASI10 Rogue agents | The agent continues to act outside its scope after a configuration change. | Behaviour baselines, scope monitoring, a kill switch, and re-evaluation after change |
Treat model output and tool output as untrusted. Validate structure,content,t and policy outside the model. Restrict outbound network paths and file handling. Log blocked actions because they can reveal attacks and weak workflow design.
OWASP’s Securing Agentic Applications Guide provides implementation guidance that can inform threat modelling and security review.
Evaluation before production
Agent evaluation needs outcome tests, not just answer scoring. Build scenarios from real tasks, edge cases, denied actions, tool failures, ambiguous requests, and adversarial content. Version the tools and policies alongside the prompt and model.
Measure task completion, tool selection, argument validity, permission compliance, recovery, latency, and cost. Count critical failures separately from averages. An agent with a 95 percent completion rate can still be unreleasable if one test shows unauthorized data access.
NIST’s Generative AI Profile supports documented, iterative testing across the lifecycle rather than one review before launch. Treat each agent release as a new candidate for the same suite.
Evaluate the trace. Confirm the agent used permitted tools, passed policy checks, and produced the correct final state. For a ticket agent, the text summary may look good, yet attach to the wrong customer record.
Use human review for judgement, usefulness, and workflow fit. Calibrate reviewers with examples and anchored scores. The dedicated LLM evaluation guide covers test sets, metrics, failure analysis, and release gates.
AI agent development cost factors
Cost rises with workflow breadth and action consequence. A read-only research assistant with two supported APIs is a different project from a financial operations agent that updates several systems.
The main drivers are workflow count, tool integrations, permission design, data preparation, evaluation depth, interface needs, deployment environment, and support. Legacy interfaces and poorly documented APIs add technical discovery. High-risk actions add threat modelling, approval design, and stronger testing.
Model usage is one operating cost, but tool calls, retrieval, tracing, evaluation, and human review can be larger. Forecast cost per completed task, not cost per model request. Include retries and failed attempts.
Ask vendors for a staged estimate: workflow discovery, prototype, secure pilot, operating review, and wider release. Each stage should have a decision gate and explicit exclusions.
Include the client’s operating effort in the budget. Subject-matter experts must define policy and review edge cases. Security teams must approve access. System owners must support connectors and incidents. A vendor estimate that omits those dependencies can appear lower but leave the sponsor with an unfunded internal workload.
The commercial model should permit the project to stop after the pilot. A platform subscription or long-term team commitment should follow evidence that the workflow creates value and can operate within its permission boundary.
A safe pilot scope
A useful pilot proves one end-to-end workflow under controlled conditions.
Set a maximum consequence for the pilot in business terms. Examples include the number of records exposed to change, the dollar value requiring approval, the recipients permitted for outbound messages, and the longest acceptable service interruption. Technical limits should trace back to that boundary.
For the ticket-triage agent, the pilot covers one support team for four weeks. The agent holds read and draft permissions only, and a support lead approves every outbound reply.
- Limit the pilot to one user group and one task.
- Use sandboxed or read-only tools where possible.
- Give the agent a dedicated, scoped identity.
- Require approval for external communication, financial change, or record mutation.
- Define success, critical failure, and stop thresholds.
- Run adversarial, recovery, and duplicate-action tests before access.
- Prepare rollback, manual completion, and incident ownership.
- Set a time boundary and hold a formal evidence review.
Google Cloud publishes a security-operations agent architecture that breaks complex investigation and triage into controlled tasks across security systems. It is a useful public case for bounded agent roles and orchestration, not a reason to grant a general agent access to an entire security stack.
Planning an agent with access to real systems? EspioLabs can define a bounded workflow, architecture, permission model, and evaluation plan before production access is granted. Plan an AI agent pilot.
Build vs. buy an agent platform.
Buying a managed platform can speed orchestration, connectors, deployment, and monitoring. Building gives the team more control over workflow, data paths, portability, and policy. Many products combine a platform runtime with custom tool and policy layers.
| Decision factor | Managed platform | Custom stack |
|---|---|---|
| Time to pilot. | Faster with supported connectors | Slower initial foundation |
| Integration | Strong for platform-native systems | Flexible for custom and legacy interfaces |
| Security control | Depends on platform identity and policy features | Can match precise control needs, with more engineering |
| Portability | Vendor formats and services may create switching costs. | Greater control if interfaces remain modular |
| Operations | The platform covers more runtime work. | The team owns scaling, tracing, and upgrades. |
| Product differentiation | Best for common workflow patterns | Best where orchestration or interaction is proprietary |
Test exit terms, data handling, model choice, tool authorization, trace export, and incident support. Do not select a platform from a connector demo alone.
Run a portability test before procurement approval. Export a representative trace, tool definition, evaluation result, and configuration. Confirm that the organization can retain its data and reproduce critical behaviour outside the platform. Full portability may not be economical, but the dependency and exit cost should be visible in the business case.
AI agent governance needs a named owner. That team controls approved models, connectors, identity patterns, retention, and version changes so individual pilots do not create incompatible security and operating practices. NIST’s AI Risk Management Framework gives that ownership a common structure through its govern, map, measure, and manage functions.
Questions for an AI agent development company
Ask how the team defines the action boundary before coding. Request a threat model and sample evaluation plan. Confirm how identities, secrets, and delegated access work. Ask which controls live outside the model and how reviewers inspect a proposed action.
The partner should explain tracing, incident response, rollback, cost forecasting, ownership, and handover. Ask who will operate the agent after launch and how a new model or tool version re-enters evaluation.
A confident promise of full autonomy is not a qualification. Look for a staged plan that can prove value under narrow permissions, then expand only after evidence.
Increase autonomy only after evidence.
Agent value comes from completing work across systems. That same ability increases consequence. Bounded workflows, dedicated identity, least privilege, validation, approval, and traceable operation let teams capture value without treating the model as a trusted operator. Start read-only. Add proposals. Add approved actions. Increase autonomy after tests, and live evidence shows that the workflow, controls, and operating team can support it.
Increase autonomy in stages, one evidence gate at a time
Each step widens the permitted action space only after tests and live operation support it.
- 1. Read-onlyAgent retrieves and summarizes. No writes.
Gate to step 2: retrieval and permission tests pass
- 2. ProposeAgent drafts updates and replies for a person to apply.
Gate to step 3: draft quality and policy compliance meet thresholds
- 3. Approved actionAgent executes after a named reviewer approves each change.
Gate to step 4: approval data shows low edit and reject rates
- 4. Bounded autonomyAgent acts alone below a set consequence limit, with sampling and rollback.
Limit set in business terms and accepted by the risk owner
Planning your first AI agent? EspioLabs designs bounded workflows, permission models, and evaluation plans before an agent touches real systems. Contact EspioLabs to plan a pilot, or explore our AI software development and R&D services.



