#Handle a disputed charge
A customer says they were charged twice. Your application needs to understand which payment they mean, check its records, and determine what it can offer. An Agent helps with interpretation. Ordinary code decides credit eligibility.
This support-case example turns a request and supplied account records into a decision and a reply. It extends contact import: once software can call an intelligent method, it can evaluate that method's contribution before proceeding.
#Before you start
Prepare the source examples on a supported host. Use the source-built CLI selected there. Configure and authenticate a supported native client.
From the checkout root, enter this example:
The inline policy in bindings/agent.ts selects Codex as an editable example choice.
Edit that Binding for a lasting choice, or use an explicit review client selection.
The included dependency and jig.ts default supply that Agent to the assessor.
#Run a case
Inspect the focused Flows and their policy, then review and run:
If the selected client is unavailable, review stops before approval. See Agent client troubleshooting.
The entrypoint supplies the fixture and two-minute deadline. This result-only
target returns its decision on stdout without creating a packet directory.
Add --json for the complete machine record, or use jig run --out ./support-result
to save result.json in a retained location. The directory must not already
exist; Jig never overwrites an earlier result.
#Expected result
The fixture supplies two settled USD 24 payments for the same invoice. The
customer names the second charge, ch-102. When the Agent identifies that
charge and amount, the result includes:
The Agent can make a different assessment; this is the expected path, not a promise of identical model output. Fixtures are synthetic. The example sends neither payments nor customer messages.
#Follow the work
Support case presents the customer request, relevant supplied charges, interpretation, checked policy decision and draft reply on one page. It follows assessment and eligibility checking. The proposal stays provisional until checks finish. Up to twelve charges are shown, including the proposed charge and any matching earlier settled payment. Complete facts remain in the input and result. Child views remain available in Inspector and on independent invocation.
Use --display web for the same views through the private browser link printed after
work starts. Completed inspection waits for explicit exit. The host’s graph and blocking
causes remain separate from application reports; plain and JSON output remain available.
#Follow the decision
Three focused Flow packages compose the decision. assess proposes a charge
ID and amount through one Agent call. check-credit applies fixed policy to
the account and proposal, without receiving customer text. resolve coordinates
both through declared slots and owns the application page:
The complete caller
also checks account identity consistency, preserves blocked and limit,
and checks cancellation before returning. The child result schema establishes
its shape. It cannot establish that the proposal deserves a credit.
The policy checks the proposed charge against supplied records:
- It belongs to the supplied account and has not already been refunded.
- An earlier settled charge has the same invoice and amount.
- The duplicate is at most USD 50, and the proposed amount matches it exactly.
Only that combination produces credit_eligible. Missing or ambiguous charge
references, contradictory amounts, and over-limit cases produce manual_review.
An already refunded charge or one without a duplicate produces no_credit.
Code constructs the reply from that decision; an Agent's claim that it sent a
credit cannot appear as the application's customer-facing answer.
#Try a convincing wrong answer
The second fixture asks for a credit even though its two payments belong to different invoices:
Suppose the Agent confidently returns this perfectly valid proposal:
Code returns no_credit, with reason no_duplicate_payment and credit: null.
If the Agent cannot identify a charge, the decision is manual_review instead.
Neither path invents a duplicate. The deterministic tests explicitly supply
the wrong proposal, so this property does not depend on persuading a live model
to misbehave during the demonstration.
Try fixtures/over-limit.json next. Its duplicate USD 75 payment exceeds the
reviewed policy even if the Agent follows the request to ignore the limit.
The result cannot include an eligible credit.
These checks constrain specific decisions. They do not guarantee correct interpretation: an Agent could select an eligible charge that the customer did not intend to dispute. Evaluate that quality separately for your application.
#Use the decision in your application
Select JSON output for a software consumer:
First check the host's status, then the Flow's outcome. For done, branch
on output.disposition. An ordinary eligible case needs no human classification;
manual_review tells the caller where judgment remains necessary. blocked
and limit preserve assessment inability. Execution errors, cancellation, and
uncertain dispatch propagate without automatic retry.
The authenticated caller must supply complete, chronological account records with unique charge IDs. Keep those records separate from customer-controlled text. The reviewed Flow contains the policy; customers cannot raise its limit through input fields or instructions.
The returned credit is a proposed next action backed by the supplied snapshot. A billing service must check current records and enforce its own authorization and idempotency before issuing it. This example does not implement a payment service or make stale eligibility safe to replay.
#Make one change
Open flows/check-credit/policy.ts and lower maximumCreditCents from 5000 to
2000. Review the edited application, then run fixtures/duplicate.json again.
For the same ch-102 assessment, the result now contains manual_review,
reason: "above_credit_limit", and credit: null. The Agent method is unchanged;
code determines the new boundary.
An application could also replace the configured assessment method while
keeping its input and result contract. As in contact import, changing its
implementation requires review, even when the caller remains unchanged.
To verify the authored policy from the repository root:
These checks cover wrong proposals, policy limits, inconsistent facts, malformed results, and honest failure. They establish application behavior using Agent substitutes, not model accuracy or production throughput.
For failed execution or uncertain dispatch, follow Troubleshooting before retrying. Next, produce a tested patch to combine Agent proposals with independent execution evidence.