AI Agents

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

10 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

What is agentic engineering and how does it differ from vibe coding?

Agentic engineering is the professional evolution of vibe coding. You're not writing code directly 99% of the time — you're orchestrating AI agents who do and acting as oversight. The key difference: vibe coding was for fun throwaway projects, agentic engineering claims the leverage of agents without compromising software quality.

moderate Andrej Karpathy AI Coding, AI Agents

How can I use AI agents to run ML experiments autonomously?

Set up a fixed-budget experiment loop: the human writes a strategy document (a Markdown file), the AI agent iterates on training code. Each experiment runs for exactly 5 minutes on a fixed metric, so every change is fairly compared. The agent commits improvements to a git branch and discards failures. 100+ experiments can run overnight without human involvement.

advanced Andrej Karpathy AI Agents, AI Coding

What is the fixed-budget ratchet for AI research?

Give every AI experiment an identical wall-clock budget (e.g. 5 minutes). Measure with a vocabulary-size-independent metric like bits-per-byte. If results improve, commit to git and make it the new baseline. If not, git reset. This "ratchet" ensures the model only ever improves — roughly 12 experiments per hour, 100+ overnight.

advanced Andrej Karpathy AI Agents

What are Claws and why are they a new AI layer?

Claws are persistent AI agent systems (like OpenClaw) that add orchestration, scheduling, context management, tool calls, and persistence on top of LLM agents. They're a new layer of the AI stack: LLMs → LLM agents → Claws. Look for implementations where the core engine is small enough to fit in your head and in an AI's context window (~4000 lines), making it manageable, auditable, and flexible.

advanced Andrej Karpathy AI Agents

Should I use config files or skills-based configuration for AI agents?

Instead of traditional config files, use a skills-based approach: write instructions that tell an AI agent how to modify actual code to add features. For example, "/add-telegram" as a skill that instructs the agent to integrate Telegram. This prevents config mess and if-then-else monsters. The meta: write maximally forkable repos and use skills to fork into any desired configuration.

advanced Andrej Karpathy AI Agents, AI Coding