Scrivio Interview library
DesignAdvanced5 min read · updated 12 November 2026

Design the architecture for an agent that helps support staff resolve billing issues by reading account data, explaining invoices and proposing credits, across five backend services.

The agent lives in its own service and reaches the five backends only through narrow, typed tools that call their existing APIs, never generic HTTP or SQL access. Read tools run freely, but action tools such as issuing a credit only create proposals that a staff member approves and that execute idempotently. Every call uses the staff member's own identity and permissions and is logged for audit, retrieval over billing policies supplies cited sources, and evaluation, cost budgets, model fallback and a kill switch are part of the design from the start.

Why this question is asked

Support staff resolving billing issues spend much of their time jumping between systems: the account system, invoices, payments, usage records and the credit tool. An agent that gathers the facts, explains the invoice and proposes a fix can save real time, but it also touches money and customer data, so the architecture matters more than the prompt. Interviewers ask this design question to see whether we can put an LLM inside a serious system with the right boundaries. In this answer, we will place the agent service, design its tools, separate reading from acting, carry identity through every call, add policy retrieval, and finish with the operational controls.

1A Quick Recap of the Moving Parts

An agent here means an LLM running a tool-calling loop: it reads the staff member's question, asks our application to run tools, reads their results, and repeats until it can answer. The five backend services already exist, say Accounts, Invoices, Payments, Usage and Credits, each with its own API and permission model. Our job is to connect the agent to them without weakening any of the controls those services already have.

2The Agent as Its Own Service With Narrow Tools

We put the agent behind its own service, a Spring Boot application with Spring AI or LangChain4j, which the support UI calls. The tools inside it are small Java methods that call the existing APIs: getAccountSummary(accountId), listInvoices(accountId, from, to), explainInvoiceLine(invoiceId, lineId), getPayments(accountId, from, to), getUsage(accountId, month), and proposeCredit(accountId, amount, reason). Each has typed parameters and returns a compact record.

The reason to avoid a generic tool such as callApi(url, body) or runSql(query) is that it gives the model the whole power of the backend, including operations nobody intended, and makes it impossible to review what the agent can do. Narrow tools turn the agent's abilities into a short list that security and the backend owners can read and approve.

Step throughBilling agent architecture
  1. Support UIstaff ask questions, approve proposals
  2. Billing agent servicemodel loop, limits, audit log, kill switch
  3. Typed toolsread tools and proposeCredit only
  4. Policy retrievalbilling policies with source ids
  5. Existing APIsAccounts, Invoices, Payments, Usage, Credits

5 layers, from the top down. Step through them one at a time.

The agent never talks to databases directly; every request passes through an existing API and its permission checks.

3Separating Read Tools From Action Tools

Reading account data is low risk; issuing credits moves money. So the agent's read tools run automatically, while its only action tool, proposeCredit, creates a pending proposal record with the amount, reason and evidence, such as the invoice line that was double charged. The staff member sees the proposal in the UI and approves or rejects it. Only approval calls the Credits service, and it does so with an idempotency key, a unique id taken from the proposal, so a retry after a timeout cannot issue the credit twice.

Notice that the model cannot skip approval, because no tool it can call issues a credit directly.

Step throughProposing and approving a credit
StaffAgent serviceModelCredits API
Why was account 881 charged twice?
question + tools
listInvoices, explainInvoiceLine, getPayments
proposeCredit(881, 49.00, duplicate line 3)
save proposal P-17, status PENDING
explanation + proposal P-17 for approval
approve P-17
issue credit, idempotency key P-17
credit C-552 issued

9 messages in order. Play them, or step through them one at a time.

4Carrying the Staff Member's Identity

Every tool call uses the identity and permissions of the staff member who asked, not a powerful service account. In practice the agent service receives the user's token from the UI and passes it on, or exchanges it for a downstream token for each backend, so the Invoices API applies the same rules it applies when that person uses the normal screens. A junior agent who cannot see enterprise accounts in the billing UI cannot see them through the AI either.

We log every model call and tool call with the staff member, account, arguments, result summary and request id. That audit trail answers the questions compliance will ask later: who saw this data, who proposed this credit and who approved it.

5Retrieval Over Policies, With Sources

Explaining an invoice often needs policy knowledge: proration rules, late fee terms, which credits are allowed. We index the billing policy documents and invoice explanation guides in a vector store, search them for each question, and give the relevant passages to the model with their ids. The answer cites them, and the UI shows the sources, so staff can check the policy themselves before telling the customer anything. If no policy supports a credit, the agent says so rather than inventing one.

6Evaluation, Costs, Fallback and a Kill Switch

Before launch we build an evaluation set of real, anonymised billing cases with known correct explanations and credits, and run it on every change to prompts, tools or model. In production we set limits per request on tool calls, tokens and time, and track cost per resolved case. A model fallback, a second model or provider behind the same gateway, keeps the service working when the main provider is down; it must also pass the evaluation set. Finally, a kill switch, a configuration flag, turns the agent off instantly and returns staff to the normal tools if something goes wrong, for example a wave of bad proposals.

7Follow-up questions

Why not let the agent issue small credits automatically?

It may be reasonable later, for very small, reversible amounts, once evaluation and the human rejection rate show the proposals are reliable. Starting with approval for every credit gives us that evidence and keeps people accountable while trust is built.

How do you stop the agent from showing one customer's data in another customer's case?

Each conversation is tied to one account id chosen in the UI, and tools take the account from the conversation context rather than from the model's arguments, or reject accounts that differ from it. Memory is never shared across conversations.

What do you measure after launch?

Time to resolve a billing case, the share of explanations staff accept, how often staff reject or edit credit proposals, policy citation accuracy in samples, and cost per case.

8Conclusion

In this answer, we designed a billing support agent as its own service with narrow, typed tools over the five existing APIs. Read tools run freely while credits are proposals that a person approves and that execute idempotently, every call carries the staff member's identity and is audited, policy retrieval gives cited sources, and evaluation, cost budgets, model fallback and a kill switch keep it safe in operation.

What to say in the interviewAbout 80 seconds aloud

Open with

I would build the agent as its own Spring Boot service that the support UI calls, with Spring AI running the tool loop. It reaches the five backends only through narrow typed tools that call their existing APIs, things like getAccountSummary, listInvoices, explainInvoiceLine, getPayments and getUsage, each returning a small record.

Then, if they want more

No generic HTTP or SQL tool, because then nobody can review what the agent can actually do. I would separate reading from acting: read tools run automatically, but the only action tool, proposeCredit, just saves a pending proposal with amount, reason and evidence.

The staff member approves it in the UI, and only then do we call the Credits API, with an idempotency key from the proposal so a retry never credits twice. Every tool call runs with the staff member's own token, so the backends apply their usual permissions, and every call is logged for audit.

I would add retrieval over billing policies and invoice guides, with the sources shown to staff. And operationally: an evaluation set of real anonymised cases run on every change, limits on steps and tokens, cost per case tracked, a fallback model behind the gateway, and a kill switch to turn the agent off instantly.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring AI reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Design the architecture for an agent that helps support staff resolve billing issues by...": https://scrivio-interview-library.netlify.app/spring-boot/ai-agents-and-mcp/e64abbd91a/