An agent that can call write operations on your Order Service needs the same guardrails as any other client with write access. Classify every tool as read-only or state-changing, and let only the state-changing ones pass through an approval gate. In the example below, the agent may call getOrder freely, but cancelOrder pauses until a human or a policy engine approves the call. The gate must live in your Java code and not in the prompt, because a prompt instruction is only a suggestion, while a code check is a guarantee. This keeps the blast radius small, and you get an audit trail of every approved action for free.

// Context: an agent talks to the Order Service only through these tools.
public interface OrderTool {
String name();
boolean changesState(); // read-only vs. state-changing
String execute(String orderId);
}
public class ApprovalGate {
private final Approver approver; // human UI or policy engine
public ApprovalGate(Approver approver) {
this.approver = approver;
}
public String call(OrderTool tool, String orderId) {
if (tool.changesState() && !approver.approves(tool.name(), orderId)) {
return "DENIED: " + tool.name() + " on order " + orderId;
}
return tool.execute(orderId); // getOrder runs directly, cancelOrder only after approval
}
}

Schreibe einen Kommentar

I’m Iman

Mein Name ist Iman Dabbaghi. Ich arbeite als Senior Software Engineer in der Schweiz. Außerdem interessiere ich mich sehr für gewaltfreie Kommunikation, Bachata-Tanz und Musik sowie fürs die Persönlichkeitsentwicklung.

Ich habe einen Masterabschluss in Informatik von der Universität Freiburg in Deutschland, bin Spring/Java Certified Professional (OCP), Certified Professional for Software Architecture (CPSA-F) und ein lebenslanger Lernender 🎓.

EN:

My name is Iman Dabbaghi. I work as a Senior Software Engineer in Switzerland. I am also very interessted in nonviolent communication, Bachata dance and music and also for personal development.

I hold a masters degree in computer science from the university of Freiburg in Germany, am a Spring / Java Certified Professional (OCP), Certified Software Architecture (CPSA-F) and Life Long Learner🎓

Let’s connect