What this prompt does
This prompt makes the AI a senior AI agent engineer that specifies a Gemini function-calling workflow automator tightly enough to build, returning working code rather than pseudocode. You provide the [model], the [tools] the agent can call, and the [max_steps] limit, and it returns the agent loop code plus an example session transcript showing tool calls and the final result.
The six deliverables pin down the agent loop, which is where these systems fail: tool definitions (name, JSON schema, description) for your [tools], ready for function calling; the control loop where the user states a goal, the model picks a tool and arguments, your code executes, results feed back, and it repeats; argument validation against each tool schema before any execution; safety checks including a confirmation gate for destructive actions and a hard step limit set to [max_steps]; structured logging of each step for replay and debugging; and a termination condition so the loop stops cleanly when the goal is met or the limit is hit. The structure works because the failure mode is always the loop - a model that picks the wrong tool or never decides it is done.
When to use it
- You are building an agent that selects and calls tools to accomplish a multi-step goal.
- You need argument validation against tool schemas before anything executes.
- Some tools are destructive and need a confirmation gate before they run.
- You want a hard step limit so the loop cannot run away.
- You need structured per-step logging to replay and debug agent runs.
Example output
You get the agent loop code: tool definitions with JSON schemas for your [tools], the control loop that lets the [model] pick a tool and arguments, validation before execution, a confirmation gate for destructive actions, a hard [max_steps] cap, structured step logging, and a clean termination condition - plus an example session transcript showing the tool calls made and the final result.
Pro tips
- Put a confirmation gate on anything destructive; an unbounded agent with a send_email or delete tool is a support ticket waiting to happen.
- Pin the control loop, validation, and
[max_steps]before adding more[tools]- the loop is the hard part, the tools are easy. - Write tight JSON schemas for each tool so argument validation actually rejects bad calls before execution.
- Set
[max_steps]low enough to bound cost and runaway behaviour but high enough to finish a real goal. - Keep structured logging on every step; when the agent misbehaves, the replay log is how you find which tool choice went wrong.
- Make the termination condition explicit, or the model may loop without ever deciding the goal is met.