Member-only story

Building Code Agent from scratch using Langgraph

Motivation

Minyang Chen
17 min readMar 5, 2025

Today’s frameworks — like AutoGen, CrewAI, PhiData, Swarm, LangChain, BeeAgent, and many more — provide powerful ways to build AI agents, but they are not the same as code agent frameworks.

Code agents are simple. They use LLMs to craft task-specific code logic that is specifically designed to be the best possible way to express actions and logic for providing answers to user questions dynamically.

Code agents are particularly beneficial for automation tasks requiring flexibility, intelligent decision-making, and adaptability to dynamic environments. However, their suitability should be evaluated based on specific use cases, balancing potential benefits against implementation challenges and limitations.

Figure-1: Code Agent Workflow Graph

In comparison, a typical multi-step agent requires the LLM to write an action in text or JSON at each step and then make calls to external tools. Over time, maintaining tool and API parameters in JSON documents becomes increasingly complex when adding or removing them.

The effectiveness of using AI code agents depends on the use case or business workflows. A good example of this approach is smolagents created by Huggingface.

When to use Code Agent?

--

--

Minyang Chen
Minyang Chen

Written by Minyang Chen

Enthusiastic in AI, Cloud, Big Data and Software Engineering. Sharing insights from my own experiences.

No responses yet

Write a response