Papiha Joharapurkar

agent systems

Hello readers! As someone who's been working with agents for almost a year now, I wanted to do a couple logs dedicated to how I understand agents and how I build them. In my day job, I am working to create agents to automate and make real world data workflows faster.

I personally like to think of agents as a big while loop. While some condition, the agent will keep working and then after the condition is fulfilled, it will stop.

while condition:
	agent goes brrrrr
return final_output

Agents are composed of 3 parts:

  1. system - the design, architecture
  2. data - the context, training examples
  3. evaluations - this is important as bad evaluations can make a bad model look great.

In this log, I will cover the agent system which has these pieces: planning and reasoning, memory, tools, actions, the environment and the LLM of course. I've done a brief dive into evaluations but will go into that in a future log, and data I can cover afterwards as well.

The agent refers to a LLM that has planning and reasoning capabilities, memories, and tools that they will use in combination to guide their actions. They will observe the environment and will act in the environment. Going back to the while loop, this means the agent can take actions and after some result from the environment is returned, the agentic loop can stop.

Planning and reasoning capabilities can help agents break down problems. There's different types of reasoning (e.g. Chain of Thought or ReACT) but in general, reasoning helps us understand why agents might take certain actions. We can use their reasoning traces to debug and adjust prompts. For instance, an agent acts in a certain way - if we look at their reasoning traces, we can deep dive on why and adjust the prompting or some other parameter.

Tools refers to external capabilities available to the model. For instance, a tool could include an isolated module such as disease-code-retrieval. We could instruct the agent that it has access to such a tool and we can provide a tool registry to the agent so that it can call this specific tool if the codes are needed by the agent to execute a task.

Memory I have covered in a prior log as well, and this refers to past experiences that can be used as specific knowledge for agents to further act on. Often, the context stream cannot retain all event data especially if agents are long-horizon working agents, so memory is important in these cases to ensure past insights can be compacted for agents to draw from afterwards for context. Not every agent needs memory - the alternative could be that data is being saved in external stores instead. In the project that I work in, rather than saving memories, we save states and checkpoints for the ID of the run so that future subagents or the agent continuing to work can retrieve that ID - I suppose in a way, this is closer to persistence rather than memory.

The environment is what the agent works in and executes actions and uses the outputs to feed back into itself. For instance, if an agent needed to run a SQL query, it could have access to a Snowflake environment and warehouse to run the query and after running, it's outputs would be returned back to the agent.

The LLM is the main brain - the reasoning agent and the degree to which it has control can impact the whole agent's flexibility. If it is the one deciding which steps to take next, which sub-agents to call, it will be a more agentic driven example. This is where the LLM is processing the memories, the plans and decide the tools to call and observe the outputs and deciding what to do next. Alternatively, if there is code deciding the next steps or actions, this is more of a workflow system rather than agentic. This dial of more agentic or more code-driven can be upto the designers of the agent system.

All daily logs