Writing Good Instructions
Theinstructions field is the most important part of your agent. A well-written prompt is the difference between an agent that works and one that frustrates users.
Structure with Sections
Break your instructions into clear sections so the LLM knows exactly how to behave:Be Specific About Tool Usage
Don’t just list tools — tell the agent when and how to use them:Set Boundaries
Tell the agent what it should NOT do:Choosing the Right Approach
Tool vs Connector
- Tool: You write the logic. Use when you need custom business logic, database queries, or APIs that aren’t in the connector catalog.
- Connector: Pre-built integration. Use for supported platforms (HubSpot, Slack, Twilio) — no code needed for the API call itself.
Tool vs Workflow
- Tool: A single action the agent can call during a conversation.
- Workflow: A multi-step pipeline that runs independently, with conditions, retries, and different step types.
Identify Patterns
Always callidentify() before agent.process(). It connects memory, traces, and metrics to the user.
Tool Patterns
One File Per Tool
Keep tools in separate files. This makes them easier to find, test, and reuse:Return Structured Data
Always return objects with clear fields. Avoid returning raw strings — the LLM interprets structured data better:Handle Errors Gracefully
Don’t let tools throw exceptions. Return error information so the LLM can inform the user:Memory Tips
Choose maxTurns Based on Use Case
Use Summarization for Long Conversations
When conversations exceedmaxTurns, older messages are dropped. Use summarizeAfter to preserve context:
Tracking Business Metrics
Usetrack() to emit events that power dashboards in the Runflow portal. Track what matters for your business:
Input Validation
Validate the input inmain() before processing. This prevents cryptic errors:
Next Steps
Core Concepts
Deep dive into Agents, Memory, Tools
Real-World Examples
See production-ready examples
Observability
Tracing and business metrics
Context Management
User identification patterns