AI Agent Development and Interview Guide: 04-Agent Architecture and LangGraph Orchestration

Explores ReAct loops and Plan-and-Execute patterns while implementing explicit StateGraphs, Checkpointer state persistence, and Human-in-the-Loop approval workflows in LangGraph.

Contents29 sections

Chapter 4: Agent Architecture and LangGraph Orchestration

Agent technical system component“technical system component”,technical system component,technical system component、technical system component、technical system component。technical system component Agent technical system component“technical system component + technical system component”technical system component。

1. technical system component:technical system component Agent

technical system component:

  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component。

technical system component Agent technical system component:

  • technical system component,technical system component;
  • technical system component,technical system component;
  • technical system component;
  • technical system component、technical system component、technical system component;
  • technical system component、technical system component。

🔥 P0 High-Frequency Must-Know: Agent technical system component Workflow technical system component?
Workflow technical system component;Agent technical system component。technical system component,technical system component Agent technical system component,technical system component。

2. ReAct、Plan-and-Execute technical system component Router

2.1 Router

technical system component。technical system component、technical system component、technical system component,technical system component“technical system component / technical system component / technical system component”technical system component。

2.2 ReAct technical system component

technical system component,technical system component,technical system component,technical system component:

TEXT
technical system component -> technical system component -> technical system component -> technical system component -> technical system component -> technical system component

technical system component;technical system component、technical system component。technical system component、technical system component。

2.3 Plan-and-Execute

technical system component,technical system component;technical system component。technical system component,technical system component,technical system component。

2.4 technical system component

technical system componenttechnical system component
technical system component/technical system componentRouter
2–5 technical system componenttechnical system component ReAct
technical system componentPlan-and-Execute + Checkpoint
technical system componentWorkflow + technical system component
technical system componenttechnical system component Pipeline

3. technical system component Agent technical system component

technical system component。technical system component Schema technical system component:

PYTHON
from typing import Literal, TypedDict


class AgentState(TypedDict, total=False):
    run_id: str
    user_id: str
    goal: str
    route: Literal["knowledge", "ticket", "human"]
    retrieved_evidence: list[dict]
    tool_calls: list[dict]
    tool_results: list[dict]
    step_count: int
    max_steps: int
    final_answer: str
    error_code: str | None

technical system component:

  1. technical system component,technical system component;
  2. technical system component、technical system component、technical system component;
  3. technical system component,technical system component;
  4. technical system component;
  5. technical system component、technical system component。

LangGraph technical system component“technical system component Python technical system component”,technical system component。technical system component Thinking in LangGraph。

🔥 P0 High-Frequency Must-Know: technical system component?
technical system component、technical system component、technical system component;technical system component,technical system component。technical system component。

4. technical system component

technical system component SDK,technical system component。

PYTHON
from typing import Literal, TypedDict

from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import END, START, StateGraph


class SupportState(TypedDict, total=False):
    query: str
    route: Literal["knowledge", "ticket", "human"]
    evidence: list[str]
    ticket_id: str
    answer: str


def classify(state: SupportState) -> dict:
    query = state["query"]
    if "technical system component" in query or "technical system component" in query:
        return {"route": "ticket"}
    if "technical system component" in query:
        return {"route": "human"}
    return {"route": "knowledge"}


def route_after_classify(state: SupportState) -> str:
    return state["route"]


def retrieve(state: SupportState) -> dict:
#    # technical system component Retriever,technical system component Evidence。
    return {"evidence": ["[S1] technical system component:technical system componentknowledge bases。"]}


def answer(state: SupportState) -> dict:
    evidence = "\n".join(state.get("evidence", []))
    return {"answer": f"technical system component:\n{evidence}"}


def create_ticket(state: SupportState) -> dict:
#    # technical system component、technical system component。
    return {"ticket_id": "T-001", "answer": "technical system component T-001"}


def handoff(state: SupportState) -> dict:
    return {"answer": "technical system component"}


builder = StateGraph(SupportState)
builder.add_node("classify", classify)
builder.add_node("retrieve", retrieve)
builder.add_node("answer", answer)
builder.add_node("create_ticket", create_ticket)
builder.add_node("handoff", handoff)

builder.add_edge(START, "classify")
builder.add_conditional_edges(
    "classify",
    route_after_classify,
    {
        "knowledge": "retrieve",
        "ticket": "create_ticket",
        "human": "handoff",
    },
)
builder.add_edge("retrieve", "answer")
builder.add_edge("answer", END)
builder.add_edge("create_ticket", END)
builder.add_edge("handoff", END)

graph = builder.compile(checkpointer=InMemorySaver())

config = {"configurable": {"thread_id": "demo-thread-1"}}
result = graph.invoke({"query": "technical system component?"}, config=config)
print(result["answer"])

technical system component Checkpointer;technical system component。LangGraph technical system component Persistence technical system component,Checkpoint technical system component、technical system component、technical system component,technical system component Persistence。

5. technical system component

technical system component。technical system component:

PYTHON
from typing import Literal
from pydantic import BaseModel, Field


class NextAction(BaseModel):
    action: Literal["search", "create_ticket", "ask_user", "finish"]
    tool_name: str | None = None
    tool_arguments: dict = Field(default_factory=dict)
    user_question: str | None = None
    final_answer: str | None = None

technical system component,technical system component:

  • tool_name technical system component;
  • technical system component Schema;
  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component。

6. technical system component

technical system component Agent Run technical system component:

  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component Token/technical system component;
  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component。
PYTHON
def guard_limits(state: AgentState) -> Literal["continue", "stop"]:
    if state["step_count"] >= state["max_steps"]:
        return "stop"

    calls = state.get("tool_calls", [])
    if len(calls) >= 2 and calls[-1] == calls[-2]:
        return "stop"

    return "continue"

technical system component,technical system component;technical system component。

🔥 P0 High-Frequency Must-Know: technical system component Agent technical system component?
technical system component、technical system component、Token technical system component;technical system component/technical system component;technical system component;technical system component;technical system component;Trace technical system component。technical system component Prompt technical system component“technical system component”。

7. technical system component

LangGraph technical system component:technical system component、technical system component、technical system component。technical system component:

technical system componenttechnical system componenttechnical system component
429、technical system componenttechnical system componentRetry Policy
technical system componentmodelstechnical system component,technical system component
technical system componenttechnical system componentInterrupt / Ask User
technical system componenttechnical system componenttechnical system component,technical system component
technical system componenttechnical system componenttechnical system component、technical system component、technical system component Trace

technical system component。technical system component、technical system component、technical system component、technical system component。

8. Checkpoint technical system component

Checkpoint technical system component,technical system component:

  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component fork technical system component。

technical system component,technical system component。technical system component Interrupt technical system component:technical system component,interrupt technical system component。technical system component Interrupts。

9. Human-in-the-Loop

PYTHON
from langgraph.types import Command, interrupt


def approve_ticket(state: SupportState) -> dict:
    decision = interrupt({
        "question": "technical system component?",
        "proposed_title": state["query"][:80],
    })
    return {"approved": bool(decision)}


## technical system component interrupt technical system component;technical system component thread_id。
## graph.invoke(Command(resume=True), config=config)

technical system component:technical system component、technical system component、technical system component、technical system component,technical system component“technical system component”。

🔥 P0 High-Frequency Must-Know: technical system component HITL?
technical system component、technical system component、technical system component、technical system component、technical system component、technical system component。technical system component,technical system component,technical system component。

10. technical system component

technical system component:

technical system component

  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component。

technical system component

  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component、technical system component;
  • technical system component。

technical system component Agent technical system component Demo technical system component。

11. technical system component Agent technical system component Agent

technical system component,technical system component“technical system component”。technical system component Agent technical system component:

  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component;
  • technical system component。

technical system component、technical system componentparallelismtechnical system component/technical system component Agent。technical system component 6 technical system component。

12. technical system component

technical system component A:technical system component

technical system component、technical system component、technical system component。technical system component;technical system component;technical system component。

technical system component B:technical system component

technical system component“technical system component”technical system component。technical system component,technical system component Checkpoint。

technical system component C:technical system component

technical system component“technical system component”technical system component。technical system component,technical system component,technical system component。

13. technical system component

🔥 P0:technical system component Agent technical system component?

technical system component、technical system component、technical system component、technical system component、technical system component、technical system component、technical system component;technical system component Schema;technical system component;technical system component;technical system component;technical system component。

🔥 P0:Checkpoint technical system component Memory technical system component?

Checkpoint technical system component/technical system component,technical system component;technical system component Memory technical system component。technical system component、technical system component,technical system component Checkpoint technical system component。

🔥 P0:technical system component Agent technical system component?

technical system component,technical system component、technical system component、technical system component、technical system component、technical system component、technical system component/technical system component。technical system component、technical system component。

⭐ P1:ReAct technical system component Plan-and-Execute technical system component?

technical system component、technical system component ReAct;technical system component、technical system component。technical system component Agent technical system component。technical system component、technical system component、technical system component、technical system component。

⭐ P1:technical system component?

technical system component Checkpoint technical system component,technical system component。technical system component、technical system component、technical system component、technical system component。

14. technical system component

  • technical system component Agent;
  • technical system component;
  • technical system component、technical system component、Checkpoint technical system component;
  • technical system component;
  • technical system component Trace technical system component;
  • technical system component。

REFERENCES

References

  1. 01Thinking in LangGraph
  2. 02Persistence
  3. 03Interrupts

Series

AI Agent Development and Interview Guide

Next step

Continue with related topics

Continue along the same topic.

Browse latest news