Skip to main content

Agent-Centric Applications

In an agent-centric application, agents carry the core of the workflow: they decide which steps to take, which systems to query and which actions to prepare. The rest of the application (user interface, APIs, data, integrations) exists to give agents context, tools and boundaries, and to let people supervise them.

Building a convincing demo of such an application takes days. Running it in production, for real users, with real data and real consequences, takes much more. Agents differ from traditional software in ways that affect every operational concern:

Traditional applicationAgent-centric application
Deterministic: same input, same outputNon-deterministic: the same request can take different paths
Code paths reviewed before releasePaths chosen at runtime by the model
Behavior changes when code changesBehavior also changes with prompts, models, tools and data
Fixed cost per requestVariable cost: depends on how many steps the agent takes
Errors are exceptionsErrors include plausible but wrong answers and wrong actions
Inputs come from users and systemsInputs also come from documents and tool results, which may contain hostile instructions

This page lists the concerns to address before deploying agent workflows to production, using Langfuse as an example platform for observability, prompt management and evaluation.

Overview of concerns​

ConcernKey question
SecurityCan the agent be tricked or misused into doing harm, leaking data, or exceeding its authority?
ObservabilityCan we see exactly what the agent did, why, and at what cost?
Quality assessmentHow do we know the agent does the job well, and stays good after changes?
Prompt and configuration managementWhich prompt, model and tool versions are running, and can we roll back?
Cost and performanceIs spend predictable and latency acceptable?
ReliabilityWhat happens when a tool, model or step fails in the middle of a task?
Human oversightWhere do people approve, correct or take over?
Change managementHow do we safely change models, prompts and tools?
Governance and complianceCan we explain, audit and justify what the agent does?

Reference stack​

The agent and the LLM gateway send traces to an observability platform. Prompts are loaded from a versioned prompt store instead of being hard-coded. Evaluations run on traces and datasets, and their findings drive the next changes.

Security​

Agents combine the risks of web applications with new ones: they act on behalf of users, read untrusted content, and decide by themselves which tools to call. The OWASP Gen AI Security Project, including its Agentic Security Initiative, describes these risks in detail.

AreaPractices
Identity and authorizationThe agent acts on behalf of the signed-in user, with that user's permissions, never with a broad technical account. Every tool call is authorized against the user's rights (see identity and access management)
Least-privilege toolsOnly the tools the agent's task needs; read-only where possible; narrow, task-oriented tools instead of generic "run any query" tools
Approvals for consequential actionsPayments, deletions, external emails and production changes require explicit human confirmation, enforced by the harness or a policy engine, not only by the prompt
Prompt injectionTreat documents, emails, web pages and tool results as untrusted data. Separate instructions from data, restrict what the agent can do after reading untrusted content, and validate outputs before acting on them
SandboxingCode execution, file handling and browsing run in isolated environments without access to production networks or credentials
SecretsCredentials stay in a secrets manager and are injected by the harness or gateway at call time. They never appear in prompts, context or traces
Data protectionClassify which data the agent may see; mask personal data where it is not needed, including in logs and traces; respect data residency and retention rules
Supply chainReview and pin MCP servers, tools, frameworks and models like any other dependency (see MCP and security)
Audit trailRecord who asked for what, what the agent did, which tools it called with which inputs, and who approved it
warning

Instructions in the system prompt ("never delete records") are not a security control. Enforce limits in code: in tool permissions, policy checks and approval steps that the model cannot bypass.

Observability​

Observability for agents goes beyond the usual metrics and logs of platform observability. Engineers need to see the full path of each task: every model call, tool call and retrieval, with inputs, outputs, timing and cost.

What to capture​

The usual structure is a hierarchy of sessions, traces and observations (spans):

Session: support conversation with customer C-1042
└── Trace: "Why was I charged twice?" 12.4 s $0.084
├── Generation: plan next step (model X) 1.8 s 2,140 tokens
├── Tool: billing.get_payments(customer=C-1042) 0.6 s
├── Retrieval: refund policy (top 5 chunks) 0.3 s
├── Generation: analyze payments (model X) 3.1 s 5,870 tokens
├── Tool: billing.prepare_refund(amount=49.00) 0.4 s awaiting approval
└── Generation: answer to customer (model X) 2.2 s 1,320 tokens
DataWhy it matters
Inputs and outputs of each stepDebugging wrong answers and wrong actions
Model, parameters, prompt versionLinking behavior to configuration
Tokens, cost, latency per stepFinding expensive or slow steps; attributing cost
Tool calls with arguments and resultsUnderstanding what the agent actually did
User, session, tenant, environmentFiltering, support cases, cost per customer
Errors and retriesReliability analysis
Scores and feedbackConnecting quality to individual traces

Standards help: OpenTelemetry defines semantic conventions for generative AI, so traces from different frameworks and tools can be collected the same way.

Example: Langfuse​

Langfuse is an open source platform for observing, evaluating and improving LLM and agent applications. It can be used as a cloud service or self-hosted, which matters when traces contain sensitive data. For observability it provides:

  • Tracing of LLM calls, tool calls, retrievals and other steps, through native SDKs, many framework integrations, and OpenTelemetry
  • Sessions and user tracking for multi-turn conversations and per-user analysis
  • Cost and latency analysis per trace, user, model and feature
  • Masking of sensitive data before it is stored
  • Gateway integration, for example with the LiteLLM proxy, so model traffic is traced centrally

Agent traces should also feed the organization's general observability: error rates, latency and cost as metrics with alerts, alongside the rest of the system.

Quality assessment​

The question "does it work?" has no simple answer for agents. Quality must be measured continuously, before and after release.

What to measure​

LevelExample metrics
OutcomeWas the task completed correctly? Was the user's problem solved?
Answer qualityCorrectness, faithfulness to sources, relevance, tone, format
TrajectoryWere the right tools called, with the right arguments, in a reasonable number of steps?
SafetyPolicy violations, data leakage, unauthorized actions attempted
EfficiencySteps, tokens, cost and time per completed task

How to measure​

MethodWhenDescription
Offline evaluation on datasetsBefore release, in CIRun the agent on a curated set of realistic tasks with expected outcomes; compare versions
Code-based checksAlwaysDeterministic assertions: valid output format, correct tool called, no forbidden action
LLM-as-a-judgeOffline and on production samplesA model grades outputs against a rubric, such as faithfulness or helpfulness; calibrate it against human judgments
Human annotationRegularly, on samplesExperts review and score traces; their labels improve datasets and judges
User feedbackIn productionThumbs up or down, corrections, accepted or rejected suggestions, linked to traces
Online experimentsReleaseCompare versions on real traffic, for example in a canary or A/B test

Langfuse supports this loop with datasets and experiments, LLM-as-a-judge evaluators that can score production traces automatically, and manual scoring for human review, all linked to the same traces (see the evaluation overview). Tools such as promptfoo and Ragas complement it for test suites and RAG-specific metrics.

tip

Every production failure is a test case. When a trace shows a wrong answer or action, add it to the evaluation dataset, so the same mistake is caught before the next release.

Prompt and configuration management​

An agent's behavior is defined by more than code: system prompts, tool descriptions, model choice and parameters all change it.

  • Version prompts outside the application code, with labels such as production and staging, so they can be updated and rolled back without a redeploy. Langfuse prompt management is one example.
  • Link every trace to the versions used (prompt, model, tools), so quality changes can be traced to configuration changes.
  • Review prompt changes like code changes, and run evaluations before promoting them.
  • Pin model versions and treat model upgrades as releases.

Cost and performance​

PracticeDescription
Limits per taskMaximum steps, tokens, time and cost per task, with defined behavior when a limit is reached
Budgets per team and tenantEnforced in the LLM gateway, for example with LiteLLM virtual keys
Model per stepSmaller, faster models for simple steps (classification, routing); the most capable models for hard reasoning
CachingPrompt caching for stable instructions and context; caching of tool results where safe
Context hygieneConcise tool results; summarizing or clearing old context in long tasks
User experienceStreaming and progress updates, so long tasks do not feel stuck
Cost monitoringCost per completed task, per feature and per customer, with alerts on anomalies

Reliability​

Agent tasks can run for minutes or hours and touch many systems. Failures in the middle of a task must not leave things half done.

  • Timeouts and retries for model and tool calls, with backoff and fallbacks to alternative models through the gateway.
  • Idempotent tools, so a retried step does not create a second refund or a duplicate ticket.
  • Durable execution for long-running work: persist the agent's state at each step, so tasks survive restarts and can resume. Workflow engines such as Temporal or AWS Step Functions, or the session features of agent platforms, provide this.
  • Graceful degradation: a clear message, a fallback to a simpler process, or a handover to a human when the agent cannot continue.
  • Kill switch: the ability to stop an agent, a tool or a feature immediately, without a deployment.

Human oversight​

  • Approval points for consequential or irreversible actions, with all the information needed to decide.
  • Escalation: the agent hands over to a person when it is uncertain, when the user asks, or when limits are reached.
  • Transparency: users see what the agent did and on which sources and data it based its answer.
  • Correction: people can edit, reject or undo the agent's proposals, and their corrections become feedback for evaluation.

Change management​

Models, prompts, tools and data change often, and each change can alter behavior in unexpected ways.

  • Run the evaluation suite on every change: prompt, model, tool, retrieval or framework version.
  • Release gradually with feature flags, canaries or A/B tests, comparing quality, cost and latency between versions.
  • Keep the previous configuration ready for immediate rollback.
  • Watch provider announcements for model deprecations, and plan migrations ahead of retirement dates.

Governance and compliance​

  • Inventory: register each agent with its owner, purpose, tools, data access and risk level in the architecture repository.
  • Risk classification under regulations such as the EU AI Act, with documentation, human oversight and logging proportional to the risk.
  • Retention rules for traces and conversations, which often contain personal data.
  • Accountability: clear ownership for each agent's behavior, its quality and its incidents.

Observability and evaluation platforms​

PlatformNotes
LangfuseOpen source; tracing, prompt management, evaluation; cloud or self-hosted
LangSmithTracing and evaluation from the LangChain team; works with other frameworks too
Arize PhoenixOpen source observability and evaluation, based on OpenTelemetry
BraintrustEvaluation-centric platform with tracing and experiments
MLflow TracingTracing and evaluation within the MLflow platform
Datadog LLM ObservabilityAgent observability inside an existing Datadog setup
Cloud platform servicesFor example AgentCore Observability and Evaluations on AWS (see agents)

Prefer platforms that accept OpenTelemetry data. Instrumentation then stays independent of the platform, and traces can also flow into the organization's general observability tools.

Production readiness checklist​

  • The agent acts with the user's permissions; tools follow least privilege
  • Consequential actions require approval enforced outside the prompt
  • Untrusted content cannot trigger actions without validation
  • Every model and tool call is traced, with user, session, versions, tokens and cost
  • Sensitive data is masked in traces; retention is defined
  • An evaluation dataset of realistic tasks exists and runs on every change
  • Production traces are scored by automated judges, user feedback and human review
  • Prompts and configurations are versioned and can be rolled back
  • Limits and budgets per task, user and tenant are enforced
  • Tools are idempotent; long tasks survive restarts
  • Escalation to humans and a kill switch exist
  • The agent is registered with an owner, purpose and risk classification