AI Agents

Building and using autonomous AI agents for complex multi-step tasks.

5 tips in this topic

Key Tips

All Tips

How do I build a simple AI agent with function calling?

Define your tools as JSON schemas, then let the model decide when to call them. Start simple: one tool for search, one for calculation. The model returns a function call instead of text, you execute it, feed results back. Loop until done.

advanced Swyx AI Agents, AI Coding

What is the ReAct pattern for AI agents?

ReAct combines Reasoning and Acting. The agent thinks out loud (Reason), takes an action (Act), observes the result, then repeats. Format: "Thought: I need to... Action: search(...) Observation: [results] Thought: Now I know..."

advanced Swyx AI Agents

What is prompt injection and how do I prevent it?

Prompt injection is when user input overrides your system instructions. Prevent it by: separating user input with clear delimiters, validating inputs, using the system message for instructions (not user message), and never trusting user input to be benign.

advanced Simon Willison AI Agents, Enterprise AI

How do I handle AI hallucinations in production?

Layer defenses: ask the model to cite sources, implement fact-checking against known databases, flag low-confidence responses for human review, and set clear expectations with users that AI can make mistakes. Never fully automate high-stakes decisions.

advanced Cassie Kozyrkov Enterprise AI, AI Agents

How do I write system prompts that stick?

Put the most important instructions at the start AND end of the system prompt (primacy and recency effects). Use clear formatting like numbered lists. Repeat critical constraints. Test with adversarial inputs to see if the model breaks character.

moderate Riley Goodside Prompt Engineering, AI Agents