Draft with AI
Draft with AI writes and edits an agent inside the draft you are working on. Describe the agent you want, or the change you want made to this one. The AI returns the whole draft with that change made, and the editor shows the result. Draft with AI is not a chatbot and not the documentation. For questions about how Search2o works, use the Docs icon at the top of the page.
What it knows
Every request carries four things, and the AI works within all of them.
How an agent is built. The AI works from the same command schema the editor and validation use: every command, the fields each command takes, how blocks run in order, and how to use a command twice (var, then var.1). It also knows the rules validation enforces, so it avoids writing what would be refused:
askcannot go inside aforloop or anonErrorblock. The AI uses awhileloop, or has the handler set a variable and asks afterwards.- A function used as a tool cannot
end. The AI usesfail, or returns a value for the model to explain. - An agent runs again on every turn of a conversation.
agent.andconv.variables carry over, and reading one that was never set fails, so the AI checks withsys.existsfirst.
Your current draft. Every request edits the draft you have open. The AI keeps every function, command, name, expression and comment that your request does not touch, exactly as you wrote them. On a new, empty draft, it builds the agent from scratch.
The agent's prompts. The AI sees each prompt's name and its doc, never the prompt's text. It names a listed prompt in every llm command. When none fits, it names a new prompt and adds a comment saying what the prompt's system and user text should say, and which variables the prompt should read. See Prompts.
This account's configuration.
| Setting | How the AI uses it |
|---|---|
| Used profiles | The AI names only the profiles you have ticked, exactly, in the command of their type. It reads each profile's notes to learn what the API serves or what the database holds. |
| Expression allowlist | Expressions call only names on the allowlist. If your request needs a function that is not there, the AI leaves that value empty and says the function must be added to the allowlist first. |
| Compile rules | The AI avoids an operator your account disallows. It writes the value another way, or leaves the value empty with a note naming the operator. |
| System variables | The AI reads only the sys variables your account makes available. sys.inputs, sys.query, sys.secret and sys.exists are always available. |
You choose the used profiles in the draft. The allowlist, compile rules and system variables come from the account's settings under Guardrails; see Allowlist, Compile rules and System variables.
What it has never seen. Your database, your API and your MCP tools are outside the AI's view, so it never writes SQL, URL paths, request parameters or tool arguments. It puts the command in the right place, leaves those fields empty, and adds a comment saying what belongs there. An invented query would fail at validation against a table that does not exist, and you would still have to write the real one.
Using it
- Open a draft from Agents › Drafts, or create a new one.
- Below the agent definition, select Draft with AI. It is selected when the page opens.
- Under Used profiles, tick the profiles the agent should use. They are saved with the draft, like its title.
- In the box, describe what you want, and select Send or press Ctrl+Enter (⌘⏎ on a Mac). Enter at least a few words, up to 10,000 characters.
Before anything is sent, the draft is saved if it has unsaved changes. The AI works from the saved draft, so the AI receives exactly what the editor shows. If the save fails, nothing is sent. While the AI is writing, the button reads Writing… and the switch to Validate is locked, so the result is always in view.
What comes back
The answer replaces the definition in the editor, and the draft is saved with it. Comments mark what is left for you: a query to write, a path to fill in. Each comment sits above the line it is about. Fill them in, delete the comments you have dealt with, and save. A request that can be completed without gaps comes back finished, with no comments. A request too vague to start from changes nothing; the AI says in a sentence or two what it would need to know.
Validate what comes back before you publish, and check that the agent does what you meant. The AI works within the rules above; validation is what proves that an agent runs.
Undo
Each AI edit can be undone. Select Undo AI edit beside the Agent definition heading. The number in the button is how many edits you can step back through, up to ten.
- Undo puts back the definition as it was before that AI edit, and saves it.
- If you have typed changes into the definition since the AI edit and not saved them, you are asked first. Keep my changes leaves everything as it is; Undo discards those changes and goes back.
- When you edit the definition yourself and save it, the undo history is cleared. From then on, the editor's own undo (Ctrl+Z) is the way back.
Tips
- Ask for one change at a time. "Add an ask for the order number before the lookup" is easier to check than a whole agent rewritten at once.
- Tick the profiles first, and keep their notes useful. A profile's notes are what the AI knows about your system. "Orders database: orders, order_lines, customers" leads to a better draft than an empty note.
- If something is refused at validation, say what the error was in your next request, or fix it in the editor. A validation error names the place in the definition it is about.

