Long AI agent prompts often mix the task with rules added after earlier failures. Separating those rules makes the workflow easier to test. The invoice scenario below illustrates the pattern; it is not a customer case study.
The agent could not map “Consulting services” to a Xero account. Someone added another sentence to the prompt: “Consulting services maps to 4000 Consulting revenue.”
The line fixed one failure. It also buried a business mapping rule inside the same text that tells the agent what to do. The next failure adds another sentence.
The lines are not all the same kind of thing.
| Category | Line added | What it becomes |
|---|---|---|
| Business mapping | “Consulting services maps to 4000 Consulting revenue.” | Mapping table |
| Identity matching | “Match customers by billing email when their Xero name is different.” | Matching rule |
| Duplicate prevention | “If the sales-order ID already exists in Xero, do not create another invoice.” | Precondition |
| Business exception | “If the PO number is missing, save the invoice as a draft.” | Conditional branch |
| Source precedence | “Use the contract currency, not the customer’s default Xero currency.” | Source-of-truth rule |
| Approval policy | “Invoices above $50,000 require finance approval before posting.” | Approval gate |
| Verification | “The number of created invoices must equal the number of eligible sales.” | Postcondition |
| Recovery | “After a timeout, check whether Xero created the invoice before retrying.” | Retry and idempotency policy |
| Timing | “Do not post usage invoices until the monthly usage period has closed.” | Temporal precondition |
| Escalation | “If two Xero contacts match, stop and ask the operator.” | Human decision point |
Why a longer prompt does not solve it.
A prompt cannot keep these concerns separate. The runtime must reinterpret the complete block every time it acts. A new edit has no clear boundary, owner, or independent test.
Store the method instead.
Method stores each concern in the structure built for it: retained values, preconditions, branches, approval gates, postconditions, and recovery rules. Each step can be run, checked, and repaired without rewriting the rest of the program.
When behavior changes, the method gets a new version. A prompt can still be generated for an agent runtime, but it is an output—not the source of truth.
Test the rule before the next real run.
For the account-mapping example, prepare one invoice line with the known label and another with an unknown label. The known label should select the approved account. The unknown label should stop for review. It should not cause the agent to invent a new mapping.
Keep those inputs with the method and compare the returned account values after a change. If the workflow can create an invoice, test the mapping before enabling that write. A timeout during a write needs an inspection of the external system before a retry.
Start with the prompt-to-agent guide, then use the SDK quickstart to run a small method and inspect its saved evidence.


