
How I Built an AI Agent That Actually Does Things (Not Just Chat)
Most AI agents are just chatbot wrappers. Send a message, get a response. That is not an agent. A real agent can read files, write code, run commands, and fix its own mistakes. Here is how. The Tool-Calling Loop User sends a message LLM responds with a tool call (not text) You execute the tool and send the result back LLM continues reasoning Repeat until done import Anthropic from " @anthropic-ai/sdk " ; const client = new Anthropic (); const tools = [{ name : " run_command " , description : " Execute a shell command " , input_schema : { type : " object " , properties : { command : { type : " string " } }, required : [ " command " ] } }]; async function agent ( task ) { let messages = [{ role : " user " , content : task }]; while ( true ) { const resp = await client . messages . create ({ model : " claude-sonnet-4-20250514 " , max_tokens : 4096 , tools , messages }); if ( resp . stop_reason === " end_turn " ) return resp . content [ 0 ]. text ; for ( const block of resp . content ) { i
Continue reading on Dev.to Webdev
Opens in a new tab



