1. Give the agent a bounded job
“Review this contract and do whatever is needed” is a poor production specification. A better agent has a defined goal, allowed actions, required outputs and clear stop conditions. For example: extract renewal terms, compare them with a playbook, flag deviations and create a review task when a clause is outside policy.
Bounded tasks are easier to evaluate and safer to automate because the agent cannot silently expand its role.
2. Separate trusted instructions from document content
Documents are data, not authority. A document can contain text that resembles instructions to a model, including malicious or accidental prompt injection. System instructions, workflow policy and tool permissions should not be overridden by content inside the file.
Prompt injection remains a serious risk in AI workflows, and retrieval does not eliminate it. Treat retrieved passages, uploaded documents and other external content as untrusted input, then constrain what the agent is allowed to do with that content.
3. Use narrow tools and least privilege
An agent that only needs to create a review task should not have permission to delete records or send payments. Create task-specific tools with explicit schemas, scoped credentials and validation at the tool boundary.
Keep read operations separate from write operations where possible. Require a workflow state transition before the agent can perform a consequential action.
4. Require evidence for decisions
When an agent flags a contract, invoice or policy, store the supporting passages, extracted fields and rules that led to the decision. A reviewer should be able to inspect the evidence without replaying the entire conversation.
Structured outputs make the handoff clearer: decision, reason, evidence references, confidence, requested action and next state.
5. Add approval before high-impact actions
High-impact actions should be gated by people or deterministic policy. The agent can prepare the work—collect evidence, compare records and propose an action—while a reviewer approves the irreversible step.
This pattern preserves much of the speed benefit while keeping accountability at the right point in the workflow.
6. Treat every external document as untrusted input
Do not expose secrets, system prompts or broad internal APIs in the same context as arbitrary document content. Validate tool arguments, constrain network access and log every tool call.
For knowledge-based agents, enforce document permissions at retrieval time so the agent cannot assemble context that the user would not be allowed to view directly.
7. Evaluate the complete task, not just the final answer
Measure task success, evidence quality, tool correctness, escalation behavior and forbidden-action rate. Include adversarial and ambiguous documents in tests, and keep evaluating the workflow after launch rather than treating pre-deployment testing as the finish line.
Agent reliability is a system property: prompts, tools, permissions, retrieval, model behavior, business rules and human review all contribute to the outcome.
Design the agent state machine explicitly
Document agents are easier to reason about when their workflow has named states such as received, extracting, comparing, awaiting review, approved, rejected and completed. Each transition should define which tools are available and what evidence is required. This prevents an agent from jumping directly from an uncertain analysis to a high-impact action.
State also helps recovery. If a tool call fails, the system can resume from a known point rather than replaying the entire agent conversation and risking duplicate actions.
Red-team the workflow, not only the prompt
Test documents containing misleading instructions, hidden text, contradictory clauses, malformed tables and content that attempts to trigger tools. Also test permission boundaries: a user with access to one workspace should not cause the agent to retrieve or act on another workspace’s data.
Evaluate what the agent does when evidence is incomplete. The safest behavior is often to stop, explain what is missing and request review rather than infer facts that were never present.