Building Agent From Scratch

When I use the Langchain Agent it feels like a black box. I want to be able to really understand how I can create an agent without using Langchain. I tried reading and understanding the “WebGPT: Browser-assisted question-answering with
human feedback” paper but I get lost.
Anyone know where I can find good documentation so I can really understand how to build agents from scratch. I believe that to be good at creating something you need to understand it intuitively

I think this is a good place to start for a very clear explanation/example implementation of the ReAct pattern—I think this would be a good starting point for what you’re looking to learn:


Use my CurtGPT! It’s about as simple as it gets for creating your own agent.

I’ve evolved it even further, and about to “cloudify” the whole thing, but need some time to wrap work related things up.


curt.kennedy, I have just tried it. I did it in VS Code Jupyter Notebook format so that I could see clearly what different sections of your code did. All I can say at this stage is that it works as you promised it would. I need to spend a bit more time with it to understand it better. Thank you.


When I use the Langchain Agent it feels like a black box


I attempted to use Langchain when I started working on an agent ~3 weeks ago, but really struggled with understanding things when they went wrong (and a lot went wrong).

I second @dliden recommendation of the Simon Willison post. I used that to get started.

My TL;DR of what has worked for me so far:

  1. Use GPT-4. It’s far better than gpt-3.5-turbo at reasoning and code completion. gpt-3.5-turbo is great for introducing chaos into your agent loop when testing.
  2. Don’t use an LLM app framework. Start with your language’s OpenAI API client and build from there.
  3. Customize your prompt context, output formats, and error handling. This is critical for getting good completions.
  4. Create/use an API replay tool. Make it easy to replay API calls as it’s too slow to copy & paste these into the OpenAI playground.
  5. Stream completions. Use the stream mode of the API to speed up dev cycles. You can quickly abort if a completion is off the rails.

Would you mind sharing some details about what you mean ‘OpenAI API client and build from there’.

Might be a bit late to jump on this. But would expect that he means use the Python package to connect to the OpenAI Api. Then build your workflow around it.