İçeriğe geç
Kodlama ve Yazılım İleri

AI Agent Mimarileri: ReAct, AutoGPT, BabyAGI, Reflexion

AI agent patterns: ReAct, plan-execute, reflection, tool use. Üretim için modern agent mimari.

YZ
Paylaş:
Agent mimari diyagram

AI agent = LLM + tools + planning + execution loop. 2023 AutoGPT viral, 2026 production-grade mimariler.

Agent Components

1. LLM (brain)
2. Tools (hands)
3. Memory (history)
4. Planning (strategy)
5. Reflection (learning)
6. Termination condition (stop)

Agent loop:
- Observe state
- Plan / decide
- Execute action
- Observe result
- Repeat until done

ReAct (Reasoning + Acting)

"Pattern (Yao et al., 2022):

Loop:
1. Thought: ne yapmalıyım
2. Action: hangi tool
3. Action Input: parametre
4. Observation: sonuç
5. → Thought (next iteration)

Until "Final Answer"

Example:
Q: Istanbul'a kaç saatte uçulur?
T: Hava durumu + Istanbul-Antalya mesafe lazım
A: search_flights
AI: {origin: ANK, dest: IST}
O: 1 saat 10 dk
T: Cevap hazır
F: Yaklaşık 1 saat 10 dakika
"

Detay: LangChain Agent

Plan-and-Execute

"İki faz:

Phase 1: Plan
- High-level LLM
- Break task into steps
- Static plan

Phase 2: Execute
- Each step
- Smaller LLM or tool
- Sequential or parallel

Avantaj:
- Daha düşük cost (planner once)
- Daha iyi long-term reasoning
- Debug kolay (plan görünür)

Dezavantaj:
- Plan adapt eksik
- Error recovery zor

Use case:
- Research project
- Multi-doc analysis
- Project planning
"

ReWOO (Reasoning Without Observations)

"Static plan + parallel execution:

Phase 1: Planner (one LLM call)
- Tüm planı baştan üret
- Tool dependency tanı
- Topological order

Phase 2: Workers (parallel)
- Independent tools concurrent
- Faster wall-clock

Phase 3: Solver (one LLM call)
- All results combine
- Final answer

Saving:
- 50-70% LLM calls vs ReAct
- 2-5x faster
- Lower cost

Limitations:
- Adapt yok
- Plan baştan yanlış = devamı yanlış
"

Reflexion

"Self-critique pattern:

Loop:
1. Try task
2. Evaluator (LLM): success?
3. If fail: reflect on why
4. Update memory (lessons)
5. Try again

Avantaj:
- Self-improvement
- Better at complex task
- Test-time learning

Disadvantage:
- More cost (multiple tries)
- May overthink simple

Use case:
- Coding (test pass check)
- Mathematical (verify solution)
- Multi-step tasks
"

Tree of Thoughts (ToT)

"Multi-path reasoning:

Instead of linear:
Generate K candidate next steps
Evaluate each (LLM judge)
Expand promising
Tree search (BFS / DFS)

Use case:
- Strategy games
- Logic puzzles
- Creative writing (explore variations)

Cost: high (K^depth)
Benefit: better quality for hard problems

AutoGPT Pattern

"AutoGPT (popular early 2023):

Loop:
1. LLM read goal
2. LLM plan next action
3. Execute
4. Update memory
5. Continue until 'goal achieved'

Issues:
- Infinite loops
- Repetitive actions
- Hallucinated goals
- High cost
- No human-in-loop

Status 2026:
- Pattern legacy
- Production prefer LangGraph
- Lessons learned shape modern agents
"

BabyAGI

"Task queue pattern:

Components:
- Task creator (creates subtasks)
- Task prioritizer (queue)
- Task executor

Memory: vector DB
Goal-driven: top objective splits

Avantaj:
- Long-running
- Goal hierarchy

Dezavantaj:
- Convergence problem
- Cost grow
- Goal drift
"

Modern Production Agent

"2026 best practice:

Stack:
- LangGraph (stateful)
- ReAct-style + plan when needed
- Tool result validation
- Human-in-loop (high-stakes)
- Observability (LangSmith)
- Cost cap (max iterations, max tokens)
- Timeout
- Retry + fallback

Pattern:
- Workflow over auto-agent
- Structured > autonomous
- Predictable > generic
"

Detay: LangChain Agent, Multi-Agent

Tool Use Patterns

Function Calling

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {"type": "string"}
                },
                "required": ["city"]
            }
        }
    }
]

response = openai.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hava nasıl İstanbul?"}],
    tools=tools,
    tool_choice="auto"
)

Parallel Tool Use

"GPT-4o, Claude 3.5+ support:

Multiple tools concurrent
1 LLM call → multiple actions
Faster execution

Example:
'İstanbul + Ankara + İzmir hava karşılaştır'
→ 3 parallel get_weather calls
→ Combine results
→ 1 final LLM call

Speed: 1.5x-3x faster
Cost: same total tokens but fewer round-trips
"

Tool Selection

"Many tools, which to use?

Naive: all tools every call
Problem: confusion, slower

Solutions:
1. Manual: hard-coded subset
2. Embedding-based: retrieve relevant tools
3. Hierarchical: category → specific
4. LLM router: small LLM picks tools

For 50+ tools: vector embedding retrieval
"

Memory Patterns

"Agent memory types:

Short-term:
- Conversation buffer
- Last K messages
- Session-scoped

Long-term:
- Vector DB
- Summarize past
- Episodic memory

Semantic:
- Knowledge graph
- Entity linking
- Fact storage

Procedural:
- Past actions
- Success patterns
- Tool preferences

Persistent:
- DB-backed
- User-scoped
- Multi-session
"

Human-in-the-Loop (HITL)

"Agent autonomy levels:

Level 0: No autonomy (chat)
Level 1: Suggested actions (approve each)
Level 2: Approval threshold ($100+)
Level 3: Sensitive ops only (delete, send)
Level 4: Audit log only
Level 5: Full autonomous (risky)

Production: Level 2-3 typical

Patterns:
- Interrupt before execute
- Periodic check-in
- Email summary
- Real-time dashboard
- Slack approve
"

Safety + Guardrails

"Agent safety:

Input:
- Prompt injection
- Jailbreak attempts
- PII removal

Tools:
- Whitelist
- Permission scope
- Rate limit per tool
- Cost cap

Output:
- Content filter
- Hallucination check
- Source verification
- PII output filter

Execution:
- Sandboxed (Docker, VM)
- No filesystem write
- No network unfiltered
- Timeout per action
- Max iteration

Audit:
- Log every action
- Log every prompt
- Log every result
- Replay capability
"

Cost Management

"Agent cost reality:

Single ReAct invocation:
- 5-20 iterations typical
- ~5K input + 1K output tokens
- $0.03-0.30 per call (GPT-4o)

Concurrency:
- 100 calls/day = $30-300/day
- $1K-10K/month

Optimization:
- Use cheaper model for tools (GPT-4o-mini)
- Cache common queries
- Prompt compression
- Reduce iterations
- Hybrid (small + big model)
"

Detay: Prompt Caching

Evaluation

"Agent eval:

Task completion:
- Success rate
- Steps to complete
- Token cost
- Latency

Quality:
- LLM-as-judge
- Human eval
- Specific benchmarks (WebArena, HumanEval)

Robustness:
- Edge case
- Adversarial inputs
- Tool failure
- Long-running

Tools:
- LangSmith
- BrainTrust
- DeepEval
- TruLens
"

Use Case’ler

"Production agents 2026:

Customer support:
- Ticket triage
- Multi-step troubleshoot
- Knowledge base lookup

DevOps:
- Incident response
- Log analysis
- Runbook execution

Data analysis:
- SQL generation
- Multi-step research
- Report generation

Code:
- Pull request review
- Multi-file refactor
- Test generation

Research:
- Literature review
- Comparison analysis
- Synthesis report
"

Yaygın Hatalar

  1. Infinite loop: max_iter şart
  2. Tool description vague: Wrong selection
  3. Memory unbounded: Token explode
  4. No human checkpoint: Catastrophic action
  5. No cost cap: Surprise bill
  6. Generic prompt: Drift
  7. No eval: Production blind

Sonraki Adımlar

Özet

AI agent = LLM + tools + planning + execution. ReAct (simple), plan-execute (complex), Reflexion (hard task). Anahtar: human-in-loop, safety, cost cap, eval. 2026 production: LangGraph stateful + observability.

Paylaş:

Yapay zeka dünyasından haberdar olun

Haftalık özet bültenimize abone olun, en yeni rehberler ve araç incelemeleri direkt e-postanıza gelsin.

İstediğiniz zaman abonelikten çıkabilirsiniz.