#249 Enterprise architecture and AI agents 6.1 min
Build a Minimal AI Agent Platform: Gateway, Registry, Audit
I built an agent platform in 100 lines, and switched an agent off by changing one flag in the registry.
Predict the nine calls
Copy the code folder first. Read the CALLS list in compare.py and the checks in core.py. Write down the status code you expect for each of the nine calls, then run python compare.py and compare. You should see 4 of 9 calls were done.
A hint
The checks run in order: registered, active, tool exists, scope, budget.
Give the support agent more budget
In compare.py, change the support agent budget from 4.0 to 6.0. Predict which call changes, then run python compare.py. You should see 5 of 9 calls were done, 4 stopped, with the refund for cat now done and the refund for dan still refused for budget. Then change 6.0 back to 4.0 before the next task.
A hint
A read costs 0.5 and a refund costs 2.0, as set in the TOOLS table in core.py.
Grant a missing scope
In compare.py, add "email:send" to the scopes of the support agent. Run python compare.py and find the call that changes. The send_email call for ana should now be done, and the total should be 5 of 9. Then remove it again before the next task.
A hint
The scopes are a set inside the Agent line for support-agent.
Tamper with the audit log
In compare.py, just before the line registry.suspend("billing-bot"), add this line: audit.lines[2] = audit.lines[2].replace("403", "200"). Run python compare.py and read the last line, which should say chain intact: False. Then move the edit to change audit.lines[-1] after the last call and see what the check says about the final line.
A hint
The final line has no later line carrying its hash, so think about what the check can compare it with.
These tasks are for you to try on your own machine. Nothing is checked or saved.
What this does not show
A teaching platform in one process and in memory: no real caller identity, no database, a budget counter that never resets, a hash chain that cannot see changes to its last line, and nothing here stops an agent going round the gateway.
Up next in Enterprise architecture and AI agents
More in Enterprise architecture and AI agents
Related videos
- #230 Agent Gateway: One Front Door for Models, Tools, Agents Enterprise architecture and AI agents
- #229 A Reference Architecture for Enterprise AI Agents, as Code Enterprise architecture and AI agents
- #234 Authorisation for AI Agents With Policy as Code (Cedar) Enterprise architecture and AI agents
- #235 An End-to-End Audit Trail for AI Agent Actions in Python Enterprise architecture and AI agents
