#240 Enterprise architecture and AI agents 5.8 min
Wrap Legacy APIs for AI Agents: OpenAPI to Checked Tools
Seven operations in the old API, four tools for the agent, and only two of six test calls got through.
Count the operations and tools
Copy the code folder first. Run python compare.py and read the first line. Then open spec.py and list the seven operation ids. Write down which three operations are not on the SAFE list in compare.py and why an agent should not have them.
A hint
The three that are left out are in the description as delete, export and health.
Change the maximum
In spec.py, change "maximum": 100 to "maximum": 1000 in the refund operation. Predict what happens to the refund of 500, then run python compare.py. When I ran it the refund of 500 was sent and the last line said 3 of 6 calls reached the legacy API. Then change 1000 back to 100 before the next task.
A hint
The amount is checked against the maximum in the schema.
Add one more allowed operation
In compare.py, add "deleteCustomer" to the SAFE set. Predict the first line and the last line of the output, then run python compare.py. The legacy API here is only a function that records the request, so nothing real is deleted. When I ran it the agent was given 5 tools and 3 of 6 calls reached the legacy API. Then remove deleteCustomer from the SAFE set again before the next task.
A hint
Adding one name to the allow list is all it takes to make a tool, which is why the list needs care.
Try a negative refund
In compare.py, add a seventh call to the CALLS list: ("refundOrder", {"id": 7, "amount": -5}). Predict whether it is stopped, then run python compare.py. When I ran it the call was sent and the last line said 3 of 7 calls reached the legacy API. Write one sentence on which check you would add.
A hint
The schema only has a maximum, so a negative number passes.
These tasks are for you to try on your own machine. Nothing is checked or saved.
What this does not show
A made-up API with seven operations and six hand-written calls; no model or agent runs. The checks cover missing, unknown, wrong type and one maximum, so a negative refund still passes. No nested bodies, headers, authentication, user identity or approval step.
Up next in Enterprise architecture and AI agents
More in Enterprise architecture and AI agents
- #229 A Reference Architecture for Enterprise AI Agents, as Code
- #230 Agent Gateway: One Front Door for Models, Tools, Agents
- #231 MCP Gateway: Per-Tool Policy for Agent Tools (Python)
- #232 Give Every AI Agent Its Own Identity
- #233 Delegated Authority: Let an AI Agent Act for a User, Safely
- #234 Authorisation for AI Agents With Policy as Code (Cedar)
