spinny:~/writing $ vim agentic-ai-frameworks-comparison.md
1~2AI agents अब research demos से production systems में आ गए हैं। 2026 तक 60% से अधिक enterprise AI applications में agentic components शामिल होने की उम्मीद है। लेकिन agents को scratch से बनाना - tool loops, state, memory, error handling, और multi-agent coordination को manage करना - जटिल है। यहीं पर frameworks काम आते हैं।3~42026 में चार frameworks प्रमुख हैं: **LangGraph**, **CrewAI**, **OpenAI Agents SDK**, और **Claude Agent SDK**। हर एक एक ही समस्या के लिए मूल रूप से अलग दृष्टिकोण अपनाता है: LLMs को reason करने, plan बनाने, tools का उपयोग करने, और collaborate करने की क्षमता देना।5~6## एक नज़र में7~8| पहलू | LangGraph | CrewAI | OpenAI Agents SDK | Claude Agent SDK |9|--------|-----------|--------|-------------------|-----------------|10| **निर्माता** | LangChain | CrewAI Inc. | OpenAI | Anthropic |11| **Architecture** | Graph-based | Role-based | Handoff-based | Autonomous loop |12| **दर्शन** | अधिकतम नियंत्रण | Team collaboration | न्यूनतम abstraction | Agent को computer दो |13| **भाषाएं** | Python, TypeScript | Python | Python | Python, TypeScript |14| **Model support** | कोई भी (OpenAI, Claude, local) | कोई भी | कोई भी (नाम के बावजूद) | केवल Claude |15| **GitHub stars** | ~29k | ~40k | ~21k | ~6k |16| **सबसे अच्छा** | Complex stateful workflows | Multi-agent specialization | Routing और triage | Coding और file-heavy tasks |17~18## LangGraph: The Graph Builder19~20LangGraph agent workflows को **directed cyclic graphs** के रूप में model करता है। आप nodes (functions जो काम करती हैं) और edges (उनके बीच transitions, वैकल्पिक रूप से conditional) define करते हैं। State graph से होकर बहता है और checkpointing के माध्यम से persist होता है।21~22यह सबसे explicit और controllable framework है - आप हर step को खुद wire करते हैं।23~24```mermaid25graph LR26 Start --> Router[Router Node]27 Router -->|needs research| Research[Research Node]28 Router -->|needs code| Code[Code Node]29 Research --> Synthesize[Synthesize Node]30 Code --> Synthesize31 Synthesize --> End32```33~34### मुख्य अवधारणाएं35~36- **StateGraph**: typed state के साथ graph definition37- **Nodes**: Python functions जो state को transform करती हैं38- **Edges**: nodes के बीच connections, conditional हो सकती हैं39- **Checkpointing**: long-running workflows के लिए built-in persistence40~41### Code Example42~43```python44from langgraph.graph import StateGraph, MessagesState, START, END45from langchain_openai import ChatOpenAI46~47llm = ChatOpenAI(model="gpt-4o")48~49def call_agent(state: MessagesState):50 response = llm.invoke(state["messages"])51 return {"messages": [response]}52~53def should_continue(state: MessagesState):54 last = state["messages"][-1]55 if last.tool_calls:56 return "tools"57 return END58~59def call_tools(state: MessagesState):60 # Execute tool calls and return results61 results = []62 for tool_call in state["messages"][-1].tool_calls:63 result = execute_tool(tool_call)64 results.append(result)65 return {"messages": results}66~67graph = StateGraph(MessagesState)68graph.add_node("agent", call_agent)69graph.add_node("tools", call_tools)70graph.add_edge(START, "agent")71graph.add_conditional_edges("agent", should_continue, {"tools": "tools", END: END})72graph.add_edge("tools", "agent")73~74app = graph.compile()75result = app.invoke({"messages": [{"role": "user", "content": "What's the weather?"}]})76```77~78### ताकतें79~80- हर step और transition पर बारीक नियंत्रण81- Built-in checkpointing और human-in-the-loop82- पूर्ण TypeScript parity83- किसी भी LLM provider के साथ काम करता है84- Conditional branching और loops वाली complex workflows के लिए सबसे अच्छा85~86### कमज़ोरियां87~88- सीखने का curve तेज है - आपको graph theory concepts समझने होंगे89- साधारण use cases के लिए verbose - एक basic agent को अन्य frameworks की तुलना में अधिक boilerplate चाहिए90- LangSmith के बिना graph flows को debug करना चुनौतीपूर्ण हो सकता है91~92### मूल्य निर्धारण93~94Open-source (MIT)। LangSmith (managed observability platform) में production monitoring के लिए paid tiers हैं।95~96## CrewAI: The Team Assembler97~98CrewAI एक मानवीय रूपक का उपयोग करता है: आप विशेष agents की एक **crew** बनाते हैं, जिनमें से प्रत्येक की एक **role**, **goal**, और **backstory** होती है। Agents **tools** का उपयोग करके **tasks** पर collaborate करते हैं, जिन्हें एक **process** (sequential, hierarchical, या consensual) द्वारा coordinate किया जाता है।99~100इसे एक team hire करने जैसा समझें जहां हर सदस्य का एक specific job title और specialty है।101~102```mermaid103graph TD104 Crew[Crew Manager] --> R[Researcher\nRole: Find data\nTools: WebSearch]105 Crew --> W[Writer\nRole: Write content\nTools: FileWrite]106 Crew --> E[Editor\nRole: Review quality\nTools: FileRead]107 R --> Task1[Research Task]108 W --> Task2[Writing Task]109 E --> Task3[Review Task]110 Task1 --> Task2 --> Task3111```112~113### मुख्य अवधारणाएं114~115- **Agent**: role, goal, backstory, और tools के साथ एक persona116- **Task**: description, expected output, और assigned agent के साथ एक assignment117- **Crew**: साथ मिलकर काम करने वाले agents का समूह118- **Process**: execution strategy (sequential, hierarchical, consensual)119- **Flow**: कई crews को जोड़ने के लिए event-driven orchestration layer120~121### Code Example122~123```python124from crewai import Agent, Task, Crew, Process125~126researcher = Agent(127 role="Senior Research Analyst",128 goal="Find comprehensive data about the given topic",129 backstory="You have 10 years of experience in technology research. "130 "You are thorough and always verify facts from multiple sources.",131 tools=[web_search_tool],132 verbose=True,133)134~135writer = Agent(136 role="Technical Writer",137 goal="Create clear, engaging technical content",138 backstory="You write for a developer audience. "139 "Your articles are practical and include code examples.",140 tools=[file_tool],141 verbose=True,142)143~144research_task = Task(145 description="Research the latest developments in WebAssembly in 2026. "146 "Focus on WASI, Component Model, and production use cases.",147 expected_output="A structured research document with key findings and sources.",148 agent=researcher,149)150~151writing_task = Task(152 description="Write a blog post based on the research. "153 "Include code examples and Mermaid diagrams.",154 expected_output="A complete blog post in Markdown format.",155 agent=writer,156 context=[research_task], # Writer receives researcher's output157)158~159crew = Crew(160 agents=[researcher, writer],161 tasks=[research_task, writing_task],162 process=Process.sequential,163 verbose=True,164)165~166result = crew.kickoff()167print(result.raw)168```169~170### ताकतें171~172- सहज role-based abstraction - समझने में आसान173- 100+ built-in tool integrations174- Agents के बीच shared memory (short-term, long-term, entity)175- सबसे बड़ा community (~40k GitHub stars)176- एक "manager" agent के साथ hierarchical process जो delegate और validate करता है177~178### कमज़ोरियां179~180- LangGraph की तुलना में कम बारीक नियंत्रण - आप roles define करते हैं, exact execution paths नहीं181- Hierarchical process अप्रत्याशित हो सकता है जब agents असहमत हों182- Multi-agent conversations को debug करना single-agent flows से कठिन है183~184### मूल्य निर्धारण185~186Open-source core (free)। CrewAI Platform: $99/month (Teams) से $120k/year (Enterprise)। मूल्य live crews और monthly executions पर आधारित।187~188## OpenAI Agents SDK: The Router189~190OpenAI Agents SDK (Swarm का spiritual successor) **handoffs** पर केंद्रित है - agents conversations को अन्य specialized agents को transfer करते हैं। यह सबसे minimal framework है: agents, tools, handoffs, और guardrails। बस इतना।191~192```mermaid193graph LR194 User --> Triage[Triage Agent]195 Triage -->|billing question| Billing[Billing Agent]196 Triage -->|refund request| Refund[Refund Agent]197 Triage -->|technical issue| Support[Support Agent]198 Billing --> Response[Response]199 Refund --> Response200 Support --> Response201```202~203### मुख्य अवधारणाएं204~205- **Agent**: model + instructions + tools + handoffs206- **Handoff**: दूसरे agent को transfer (LLM द्वारा call किए जाने वाले tool के रूप में modeled)207- **Guardrail**: agent के साथ parallel में चलने वाला input/output validation208- **Runner**: agent loop को execute करता है209- **Tracing**: सभी LLM calls, tool invocations, और handoffs के लिए built-in observability210~211### Code Example212~213```python214from agents import Agent, Runner, handoff, InputGuardrail, GuardrailFunctionOutput215from pydantic import BaseModel216~217class SafetyCheck(BaseModel):218 is_safe: bool219 reason: str220~221async def content_safety(ctx, agent, input_text):222 result = await Runner.run(223 Agent(name="Safety", instructions="Check if input is safe. No PII."),224 input_text,225 context=ctx,226 )227 output = SafetyCheck.model_validate_json(result.final_output)228 return GuardrailFunctionOutput(229 output_info=output, tripwire_triggered=not output.is_safe230 )231~232billing_agent = Agent(233 name="Billing Agent",234 instructions="You handle billing inquiries. Be precise with numbers.",235 tools=[lookup_invoice, process_payment],236)237~238refund_agent = Agent(239 name="Refund Agent",240 instructions="You process refund requests. Always verify the order first.",241 tools=[lookup_order, issue_refund],242)243~244triage_agent = Agent(245 name="Triage Agent",246 instructions="Route the customer to the right specialist. "247 "Ask clarifying questions if needed.",248 handoffs=[billing_agent, refund_agent],249 input_guardrails=[InputGuardrail(guardrail_function=content_safety)],250)251~252result = await Runner.run(triage_agent, "I need a refund for order #4521")253print(result.final_output)254# The triage agent routes to refund_agent, which processes the refund255```256~257### ताकतें258~259- Clean handoff pattern - routing/triage workflows के लिए स्वाभाविक260- Guardrails execution के साथ parallel में चलती हैं (fail-fast, blocking नहीं)261- Debugging के लिए built-in tracing dashboard262- नाम के बावजूद, non-OpenAI models को support करता है263- Minimal abstraction - समझने और extend करने में आसान264~265### कमज़ोरियां266~267- LangGraph की तुलना में कम mature state management268- कोई built-in persistence या checkpointing नहीं269- Third-party tools का ecosystem छोटा है270- Handoff-centric design हर architecture के लिए उपयुक्त नहीं हो सकता271~272### मूल्य निर्धारण273~274Open-source (MIT)। आप जो भी model use करें उसके लिए per-token भुगतान करें।275~276## Claude Agent SDK: The Developer277~278Claude Agent SDK एक अलग दृष्टिकोण अपनाता है: workflows या roles define करने के बजाय, आप agent को **tools का एक set देते हैं और उसे यह पता लगाने देते हैं कि task कैसे पूरा करना है**। यह वही autonomous loop उपयोग करता है जो Claude Code को power करता है - read, act, verify, iterate।279~280```mermaid281graph TD282 Prompt[User Prompt] --> Loop[Autonomous Agent Loop]283 Loop --> Reason[Reason about next step]284 Reason --> Act[Execute tool]285 Act --> Verify[Check result]286 Verify -->|not done| Loop287 Verify -->|done| Output[Final output]288```289~290### मुख्य अवधारणाएं291~292- **query()**: agent loop शुरू करने का main entry point293- **Built-in tools**: Read, Write, Edit, Bash, Glob, Grep, WebSearch, WebFetch294- **MCP के माध्यम से custom tools**: in-process MCP servers के रूप में tools define करें295- **Sub-agents**: specialized agents जिन्हें parent delegate कर सकता है296- **Sessions**: कई interactions में context बनाए रखें297~298### Code Example299~300```typescript301import { tool, createSdkMcpServer, query } from "@anthropic-ai/claude-agent-sdk";302import { z } from "zod";303~304const searchDocs = tool(305 "search_docs",306 "Search the internal documentation for relevant information",307 { query: z.string().describe("Search query") },308 async ({ query }) => {309 const results = await vectorStore.similaritySearch(query, 5);310 return {311 content: [{ type: "text", text: results.map(r => r.pageContent).join("\n\n") }],312 };313 }314);315~316const docsServer = createSdkMcpServer({317 name: "docs",318 version: "1.0.0",319 tools: [searchDocs],320});321~322for await (const message of query({323 prompt: "Find how authentication works in our system and write a summary",324 options: {325 mcpServers: { docs: docsServer },326 allowedTools: ["Read", "Glob", "Grep", "mcp__docs__search_docs"],327 },328})) {329 if (message.type === "result" && message.subtype === "success") {330 console.log(message.result);331 }332}333```334~335### ताकतें336~337- First-class MCP integration - किसी भी MCP server ecosystem से जुड़ें338- File operations, terminal, और web access के लिए built-in tools339- बड़े codebases के लिए automatic context compaction340- Complex tasks के लिए sub-agent parallelism341- Claude Code जैसा ही engine - असली development workflows पर battle-tested342~343### कमज़ोरियां344~345- केवल Claude models - कोई multi-provider support नहीं346- छोटे community के साथ नया framework347- Python SDK के लिए भी Node.js runtime आवश्यक348- LangGraph की तुलना में कम explicit workflow control349~350### मूल्य निर्धारण351~352Open-source। Standard Claude API token rates। Managed Agents (hosted version): token costs के अलावा $0.08 per session-hour।353~354## कब किसे चुनें355~356```mermaid357graph TD358 Start{What's your priority?}359 Start -->|Full control over workflow| LG[LangGraph]360 Start -->|Multi-agent collaboration| CA[CrewAI]361 Start -->|Routing and triage| OA[OpenAI Agents SDK]362 Start -->|Coding and file automation| CS[Claude Agent SDK]363~364 LG --> LGU[Complex stateful workflows\nConditional branching\nHuman-in-the-loop]365 CA --> CAU[Team of specialized agents\nResearch + writing pipelines\nContent generation]366 OA --> OAU[Customer service routing\nMulti-step handoffs\nInput validation]367 CS --> CSU[Code generation and review\nFile-heavy automation\nMCP tool ecosystem]368```369~370### LangGraph चुनें अगर:371- आपको workflow के हर step पर सटीक नियंत्रण चाहिए372- आपके use case में complex conditional logic और loops शामिल हैं373- आपको built-in persistence और human-in-the-loop checkpoints चाहिए374- आपको एक ही workflow में कई LLM providers use करने हैं375~376### CrewAI चुनें अगर:377- आप एक सहज, role-based abstraction चाहते हैं378- आपके task में अलग-अलग specialties वाले कई agents शामिल हैं379- आपको agents को collaborate करने और एक-दूसरे को context pass करने की ज़रूरत है380- आप सबसे बड़ा community और सबसे अधिक built-in integrations चाहते हैं381~382### OpenAI Agents SDK चुनें अगर:383- आपका प्राथमिक pattern conversations को specialists तक route करना है384- आपको guardrails चाहिए जो input/output को parallel में validate करें385- आप सबसे सरल possible abstraction चाहते हैं न्यूनतम boilerplate के साथ386- Built-in tracing और observability महत्वपूर्ण हैं387~388### Claude Agent SDK चुनें अगर:389- आपके agents को code read, write, और execute करना है390- आप first-class MCP server integration चाहते हैं391- आपको autonomous agents चाहिए जो iterate और self-correct करें392- आप पहले से Claude use कर रहे हैं और सबसे गहरा integration चाहते हैं393~394## क्या आप Frameworks को Combine कर सकते हैं?395~396हां। एक सामान्य pattern है orchestration के लिए एक framework और individual agents के लिए दूसरा:397~398- **LangGraph** overall workflow graph के लिए399- **CrewAI** एक specific node के लिए जिसमें multi-agent collaboration चाहिए400- **Claude Agent SDK** MCP के माध्यम से coding-related sub-tasks के लिए401- **OpenAI Agents SDK** customer-facing triage और routing के लिए402~403ये frameworks परस्पर अनन्य नहीं हैं। अपने system के हर हिस्से के लिए जो fit करे वो इस्तेमाल करें।404~405## निष्कर्ष406~407हर framework एक स्पष्ट दांव लगाता है:408~409- **LangGraph** control के लिए optimize करता है - आप हर transition तय करते हैं410- **CrewAI** collaboration के लिए optimize करता है - agents एक team के रूप में काम करते हैं411- **OpenAI Agents SDK** simplicity के लिए optimize करता है - minimal abstraction, clean handoffs412- **Claude Agent SDK** autonomy के लिए optimize करता है - tools दो और काम करने दो413~414सही चुनाव आपके workflow, आपकी team, और आपके मौजूदा stack पर निर्भर करता है। वो चुनें जो आपके primary use case से मेल खाता हो, उसे अच्छी तरह सीखें, और जब उनके sweet spot पर पहुंचें तो दूसरों को शामिल करें।415~
NORMAL · agentic-ai-frameworks-comparison.md [readonly]415 lines · :q to close