So to answer your questions, you can use the AI Agent with the custom n8n Workflow tool, which will “outsource” the task to a sub-workflow using the HTTP request node. This way you should have better control over the request and also add authentication if necessary.
Then you could use the returned response for the 2nd tool (Custom Code Tool) for your further coding endeavors. It’s important to rename the output of the HTTP Request node to response so that the agent can read it.
We made a little example workflow below to demonstrate (using some simple upperCase() functionality for the code as example).
The importance here is that you structure the prompt in the AI Agent well enough, that it will use the tools correctly.