45 Comments
User's avatar
Bobby Montalvo's avatar

I'm trying to follow along with this tutorial but the formatting is off and python is picky about formatting. I've read your comment about "full code can be found in my repo" but it's not obvious where in the repo this code is. Care to provide a link to the .py file for this tutorial please?

Pedro Marques's avatar

Copy all tutorial send to deepseek and ask for the code all togheter :)

David Stark's avatar

Yes, same problem. It looks like the formatting was off.

Nir Diamant's avatar

what is the problem?

David Stark's avatar

The State class that uses a TypedDict at the beginning. The formatting is all off. It had me questioning if there was a novel Python syntax I had not heard of.

class State(TypedDict): text:

str classification:

str entities: List[str] summary: str

On a positive note, it's good motivation to read up on Python's TypedDict feature from the typing package.

Tingwen Zhang's avatar

Here is the corrected syntax:

class State(TypedDict):

text: str

classification: str

entities: List[str]

summary: str

The syntax

variable: type

is required for a TypedDict object.

Nir Diamant's avatar

The current version worked perfect to me, but you are welcome to open a PR to make it more stable

Tingwen Zhang's avatar

I see that in the repository

https://github.com/NirDiamant/GenAI_Agents/blob/main/all_agents_tutorials/langgraph-tutorial.ipynb

the syntax is good. The minor issue on the website, where the body of class State has newlines in the wrong place.

Rahul Pandey's avatar

My understanding of Agent is that it should be able to handle some complexity which may arise at run time. How is the above designed system different from a simple program which uses LLM to answer some questions? but in the overall flow the so called agent is a linear program flow. If you can elaborate that part

Nir Diamant's avatar

Thank for you comment! Please refer to other comments on this blog post, as I answered this question :)

Yatn Bangad's avatar

Hi Nir, I'm unable to get an answer to this question from the other comments. I understand you have intentionally demo'd a simple flow but this can very well be done with prompts to an LLM. Can you describe a more complex use case for agents?

Further, I notice that the output generated by the classification and entity extraction nodes are not being used in the summarization node. Can you you please explain what is the use of having these if this is the case? If not, can you explain how the output from those is being used in the summarization node?

Jan Andrew Bloxham's avatar

May I recommend reading Gary Marcus’ substack for a different pov.

PapayaNews's avatar

Love how you framed this as 'simpler' not 'simple.' The strategic move here isn't just building agents—it's democratizing who can build them. Every marketer, PM, and analyst who learns this shifts from AI consumer to AI composer. That's the real disruption. Subscribed

Nir Diamant's avatar

Love your comment. Thanks 😊

Plain-Signal AI News's avatar

This was a fantastic article. I really appreciated how clearly you explained the shift from isolated models to coordinated, context-aware agents, the detective analogy made it click instantly. The step-by-step LangGraph example was especially strong and made the whole concept feel far more approachable than most agent tutorials.

Thanks for taking the time to write this and share it so openly. I learned a lot, and I’ll definitely revisit parts of it. Have a great day 💎

Nir Diamant's avatar

Thanks for this wonderful feedback! I really appreciate it ☺️

Ruben Hassid's avatar

As easy as it can be.

Nir Diamant's avatar

Next time will try to make it even easier :)

Hrju Blja's avatar

Thanks for sharing this, I managed to successfully run the whole code and get the intended output.

That being said, I am struggling to see how this code (putting aside the usage of the LangGraph framework) is different from the old good hard coded and predictable series of functions calls, when an output of a function A serves as an input of a function B. What specifically is "agentic" in this code? How this agent "can dynamically adjust its focus based on what it discovers"?

Bar's avatar

How does the summarization considering the information from the previous steps (classification and entities) if it only uses state["text"] and not state["classification"] or state["entities"].

It seems that summarization logic doesn’t use the classification or entity extraction output. Please correct me if I wrong...

potentialMind's avatar

This is not an agent but a workflow.

Nir Diamant's avatar

This is a minimal version of a controllable agent

ThePizzaMaster's avatar

Me, I feel like this needs a stronger use case. It's not clear how AI chaining did something that a series of well-reasoned prompts couldn't.

Nir Diamant's avatar

Thanks for your input, Dave.

The use case in this blog post is intentionally simple, as its goal is to provide an introduction and help readers understand what agents are and how to create one.

yonlehman's avatar

As others have said, I'm uncomfortable with inventing a "new" method "ai agents" for what is good old programming that uses an ai based text processesing function. Using a, state machine abstraction is also as old computer science, in the 80 there was an attempt to have a graphical state machine engine (David Harel StateCharts) I don't think it ever became mainstream since state machines are useful for small examples. Once you have many states and many edges, especially when you introduce error handling potentially on every node, good old programming with sequencing loops and conditions is still the most straightforward and readable way to represent what you want the software to do. My main concern with you simplified example is that people not trained in software engineering will think that ai makes everything simple, anyone can vibe program without bothering to learn how to do it reliably and safely.

ManjP's avatar

Like other readers commented, it is hard to see the power of agents from this example, I understand this was intentionally simplified. Might help to link to a blog post that shows the real power, the autonomous ability to decide based on context. If the agent gets non-English input, could it translate and then summarize?

Nir Diamant's avatar

You can see many more tutorials on my GitHub. both explanations + code:

https://github.com/NirDiamant/GenAI_Agents

Salvador Lorca 📚's avatar

Good insight 😌 Can i translate part of this article into Spanish with links to you and a description of your newsletter?

Nir Diamant's avatar

Yes, please explicitly credit and link to this blog post at the beginning of your article

Salvador Lorca 📚's avatar

Thanks. Of course.

Claudia Ng's avatar

The example code looks like it could be a workflow. How do you decide whether to implement it as an agent or a workflow?

Nir Diamant's avatar

An agent can be a workflow where each step uses an LLM for a specific complicated task. This way, we have much more control over the agent.

Zachary Huang's avatar

Like your tutorial and have subscribed to your newsletter! I'm new to medium. Can I get you quick feedback on an even simpler agent https://the-pocket.github.io/PocketFlow/design_pattern/agent.html, built on an 100-line framework

I made https://substack.com/home/post/p-158349453

Ravi Teja Lanka's avatar

Hello Nir, thanks for the excellent blog post, I would like to have few inputs from you, especially with the way we use the word AI Agents, In the example you have shown as part of blog is more of an AI system which is a workflow, according to the blog from Anthropic "Building Effective Agents", an AI Agent is one which takes decisions autonomously. It would be helpful if you can write a blog on building a true AI agent, and how to distinguish when to use AI workflow and when to use an AI Agent

Nir Diamant's avatar

Thanks for your input, Ravi.

The use case in this blog post is intentionally simple, as its goal is to provide an introduction and help readers understand what agents are and how to create one.