Night Burial: Choosing an Agent Framework and Putting It into Production
A practical guide to moving from LLM demos to production agents: capability boundaries, orchestration patterns, a layered architecture that separates model decisions from execution, a read-only knowledge-and-ticket case, and security, evaluation, and rollout practices.
From tutorials to a system that actually runs
Large language models can interpret natural language, generate text, and suggest next steps in context. Those abilities do not, by themselves, make an agent that can execute work safely.
A complete agent system must turn a user goal into executable steps, pick tools, consume results, and decide whether the task is done. For engineers, the hard problems usually fall into three areas:
First, model output is uncertain. The same question can yield different plans. Tool arguments may be missing, malformed, or off-intent.
Second, external actions have real effects. Querying documents is not the same risk as changing business data. A model suggestion is not permission to execute.
Third, multi-step work must keep state. Network failures, timeouts, and human approval can interrupt a run. The system must resume, not replay every step from scratch.
So agent work should not start with “which framework has the most features.” Start with the business goal, then decide how to organize the model, state, and tools.
Draw a clear capability boundary
Conversation, workflow, and agent
A typical chat system explains and generates. It usually does not operate on external business systems.
A deterministic workflow follows predefined steps. It fits well-defined processes, limited branching, and strict audit—for example validate fields, look up records, produce a result, then wait for human approval.
An agent lets the model choose the next action from the current task and execution feedback. That fits problems whose path is not fully known in advance and that need repeated retrieval or different tools.
These three are not a ladder where each replaces the last. When the process is fixed, a workflow is usually easier to test and maintain. When the task is open-ended, an agent is more flexible. Production systems often mix them: the model understands, analyzes, and proposes candidate actions; deterministic code validates, authorizes, and executes.
Define acceptance criteria per task
“Help with tickets” is too vague to judge success. A better definition looks like:
- Identify the business category of the ticket
- Retrieve relevant handling rules from an authorized knowledge base
- Produce a grounded reply suggestion
- Escalate when information is missing or rules conflict
- Do not change ticket status or send outbound content without approval
These requirements are both the build target and the basis for evaluation and go-live. Without them, an agent can look “able to answer” without proving the answer is correct and the actions are compliant.
Prerequisites: a stable runtime base
Model access and credentials
Before development, confirm how the model is called, who may call it, acceptable latency, and input/output limits. The model must actually support the required understanding and generation. If you plan structured tool calling, verify that mechanism works; do not infer it from marketing copy.
Keep credentials in a controlled config or secret store—not in code, sample docs, or logs. Give development, test, and production different scopes so test code cannot touch live data.
Data and tools
Start with two well-bounded read-only tools, such as “search internal documents” and “get ticket details.” Each tool needs its own input validation, permission checks, timeouts, and result contract.
Knowledge data needs basic governance: deduplication, versioning, source records, and access partitions. Retrieval does not prove currency. Expired policy and current rules must be distinguishable.
A reproducible test environment
Include fixed sample tasks, controllable tool responses, and failure injection: empty retrieval, timeouts, permission denied, and malformed data.
Happy-path demos overstate reliability. An agent is trustworthy if it can stop under failure, explain why, and hand the work to the right owner.
Framework choice: compare architecture, not feature lists
Most agent frameworks cluster around a few organization styles. Treat concrete products as instances of these approaches.
Sequential chains
Break the job into consecutive steps, such as understand → retrieve → generate → check format.
The structure is easy to follow and debug, and it fits short, stable paths. Heavy branching, loops, and human pauses can make a chain hard to maintain.
When you choose this style, care about whether each step’s inputs and outputs are explicit and whether failures map to a node—not only whether you can assemble a flow quickly.
State-graph orchestration
Nodes are actions; edges are transition conditions. This fits branching, retries, pause, and resume.
A ticket flow might split after retrieval: enough evidence → draft a suggestion; insufficient evidence → ask for more information; high-risk action → an approval node.
Graphs express complex processes more cleanly, but you must design state and transitions carefully. If everything lives in an ever-growing chat log, a graph will not magically make the system clear.
Multi-role collaboration
Split work across specialized units—retrieval, analysis, review. Use this when there is real division of labor, independent checking, or parallelism.
Multiple roles do not automatically raise accuracy. If they share the same bad evidence, or the reviewer only restates the previous role, you pay more for no extra reliability.
Before adding roles, answer: are the duties actually different, how are results handed off, and who resolves conflict? If that is unclear, a single agent plus deterministic checks is usually better.
Lightweight tool loops
A propose-action → run-tool → read-result → decide loop is cheap for prototypes and a small tool set.
You still need step limits, call budgets, duplicate-action detection, and stop conditions. Otherwise the agent can loop on useless searches and repeated calls.
The point of selection is not maximum features. It is whether the framework can support the state, permissions, recovery, and observability the task needs.
A reference architecture: separate model decisions from business execution
A maintainable agent can be split into five layers:
Interaction receives requests, shows progress, collects extra information, and confirms actions.
Orchestration owns task state and decides when to call the model, run a tool, pause, or finish.
Model handles understanding, candidate plans, and generation. It does not hold unbounded access to business systems.
Tools perform controlled operations and check inputs, identity, permissions, and results.
Governance covers audit, monitoring, budgets, data protection, and risk policy.
A typical path:
User request → identity and permission checks → initialize task state → model proposes an action → validate parameters and policy → execute the tool → write results back → complete or hand off to a human.
The core rule: a model action is a candidate request, not authorization. Execution authority belongs to the tool layer and business policy together.
Case: internal knowledge retrieval and ticket suggestions
Scope
Suppose the system drafts handling suggestions from internal knowledge. Phase one is read-only query and draft generation only—no auto-closing tickets, changing accounts, or sending replies.
That limit lets you prove retrieval quality and answer reliability before opening higher-risk actions.
Task state
State should at least include user identity, ticket id, user question, retrieved evidence, execution history, current stage, and termination reason.
Do not let the model freely mutate every field. Identity, permissions, budget, and approval status belong to the program. The model may propose a category or suggestion; write it only after validation.
Evidence should record document source, version or update time, and the supporting snippet so the final output is traceable and stale material is easier to catch.
Execution flow
Read the ticket, extract the topic, then retrieve. Check relevance and permission; retry if needed, but not forever.
Then the model drafts a suggestion from evidence. Code checks required fields, valid sources, and whether the draft exceeds authorization. On failure, rewrite or escalate—do not return a polished-looking answer.
Illustrative pseudocode (not a specific API):
initialize task stateset max steps and task budgetloop until limits:generate a candidate action from current statevalidate action type, parameters, and user permissionsif human approval is required:persist state and pauseend this runif the candidate is a tool call:run the controlled toolrecord result and errorsupdate task stateif the candidate is submit answer:check evidence, content, and formatif checks pass, return the resultelse record issues and continueif still incomplete:return confirmed information, failure reason, and handoff guidance
Insufficient evidence
Distinguish “nothing relevant found,” “found material that does not cover the question,” and “sources conflict.”
Treat them differently: adjust retrieval; ask the user for more information; or flag conflict for a human. Do not fill internal business rules from the model’s ungrounded prior knowledge.
Security: keep tool calls inside business bounds
Do not trust operational instructions inside retrieved content
Documents, tickets, and tool returns may contain malicious or misleading text—ignore limits, leak data, run unrelated actions. Treat that text as data to analyze, not as policy that overrides permissions.
Permission checks cannot live only in the prompt. Even if the model is misled, the tool layer must refuse unauthorized access and illegal operations.
Separate controls for writes
Writes, deletes, and outbound messages should require confirmation, approval, or deterministic checks according to risk. Confirmation UIs must show the object, the change, and the impact—not only “continue?”
For actions that retries might duplicate, use idempotency or result verification. Do not treat every tool failure as “never executed”; a timeout can happen after the operation succeeded.
Sensitive data in logs
Observability needs enough task context, not a full dump of raw content. Redact by purpose and restrict access so credentials, personal data, and sensitive business material are not exposed to the wrong people.
Evaluation and launch: measurable results, not demo impressions
Cover happy paths, missing information, rule conflicts, unauthorized requests, and tool failures. Each sample needs an expected behavior. Judge the full path, not only the final answer.
Watch:
- Task completion: predefined business requirements met
- Evidence reliability: key claims supported by valid sources
- Tool quality: correct parameters, no useless repeated calls
- Risk control: unauthorized requests refused, high-risk actions paused
- Cost and latency: model calls, tool calls, and human intervention
Metrics trade off. Extra review may improve some quality and raise cost and latency. Tune from tests; more complexity is not automatically more reliable.
Launch in stages: offline evaluation, then read-only assistance, then actions that require human confirmation. Every stage needs a stop switch, rollback, and human takeover.
Common mistakes
Letting the model plan everything. Fixed rules, field validation, and permission decisions belong in deterministic code. Use the model where language understanding and uncertain reasoning are required.
Fixing everything with a longer prompt. Prompts describe the task; they do not replace data governance, permission control, tool validation, and state recovery. Fix the layer that is actually broken.
Assuming multi-role beats a single agent. Prove that extra roles add independent value, or you only add interaction cost and failure points.
Checking only the final answer. A correct answer can still come with unauthorized queries, wasted calls, or leaked data. Reliability covers the whole execution.
Conclusion: close a reliable loop before widening autonomy
Agent engineering is drawing a hard line between uncertain model decisions and deterministic business rules. A sound starting point is a limited read-only task, then state management, evidence tracing, tool validation, and failure handling.
A framework is only a way to organize those capabilities. What decides production readiness is a clear task definition, controlled execution rights, recoverable failure, and continuous verification. Stabilize a narrow scope first, then add tools, roles, and autonomy. That is usually more valuable than chasing full automation from day one.
