Creating agents
Agents are conversational — they decide what tools to call, ask follow-ups, and remember the thread. Ask the widget for one in plain English and it generates the TypeScript for you.
Example prompts
Create an agent called scribe that summarises any text I paste into three bullet points.
Build a support-agent that answers questions about our company handbook. Give it access to the handbook PDF.
I want a research-agent that can search the web and take notes.
Make a sales-advisor that reads my CRM via Gmail and advises me on follow-ups.
What happens
- The widget may ask one or two clarifying questions — name, personality, what tools it should have, and what files it answers about (if any).
- It writes
src/mastra/agents/<yourAgentId>.ts, picks a model tier (fast,general, orbest), equips the agent with memory, and wraps tools withcreateAgentTools. - It runs a dry-run build and hot-reloads. The agent appears in Mastra Studio’s sidebar — click to chat with it directly.
What you get
Every generated agent comes with:
- Memory — conversations persist across tabs and browser restarts.
- File handling —
queryDocumentsToolso you can upload PDFs, DOCX, XLSX, and ask questions about them (see Working with files). - A sensible model choice — the widget picks
fastfor simple agents,generalfor most,bestfor complex reasoning tasks.
Iterate
Once the agent exists, everything else in this section is a follow-up prompt to the same widget:
- “Give it a web-search tool.” → Web search
- “Let it browse websites.” → Headless browser
- “Hook it up to Telegram.” → Channels
- “Connect it to Gmail.” → Composio toolkits
- “Run it every morning at 9 am.” → Workflow scheduling (Shmastra Cloud only)
Tips
- Be specific about who the agent helps and what it refuses to do. Good instructions mean fewer follow-up fixes later.
- Name files you want the agent to know about — the widget wires them into the agent’s instructions, not just its tools.
- Save the prompt template. If you’re building several similar agents, keep the original request — subsequent agents can be generated by copy-paste with a few tweaks.