The tool-calling loop is about twenty lines. Everything that makes it work in production is in the other two hundred.