-
Notifications
You must be signed in to change notification settings - Fork 147
SGR Agent's Workflow
admin edited this page Nov 7, 2025
·
6 revisions
The following diagram shows the complete SGR agent workflow with interruption and clarification support:
sequenceDiagram
participant Client
participant API as FastAPI Server
participant Agent as SGR Agent
participant LLM as LLM
participant Tools as Research Tools
Note over Client, Tools: SGR Agent Core - Agent Workflow
Client->>API: POST /v1/chat/completions<br/>{"model": "sgr_agent", "messages": [...]}
API->>Agent: Create new SGR Agent<br/>with unique ID
Note over Agent: State: INITED
Agent->>Agent: Initialize context<br/>and conversation history
loop SGR Reasoning Loop (max 6 steps)
Agent->>Agent: Prepare tools based on<br/>current context limits
Agent->>LLM: Structured Output Request<br/>with NextStep schema
LLM-->>API: Streaming chunks
API-->>Client: SSE stream with<br/>agent_id in model field
LLM->>Agent: Parsed NextStep result
alt Tool: Clarification
Note over Agent: State: WAITING_FOR_CLARIFICATION
Agent->>Tools: Execute clarification tool
Tools->>API: Return clarifying questions
API-->>Client: Stream clarification questions
Client->>API: POST /v1/chat/completions<br/>{"model": "agent_id", "messages": [...]}
API->>Agent: provide_clarification()
Note over Agent: State: RESEARCHING
Agent->>Agent: Add clarification to context
else Tool: GeneratePlan
Agent->>Tools: Execute plan generation
Tools->>Agent: Research plan created
else Tool: WebSearch
Agent->>Tools: Execute web search
Tools->>Tools: Tavily API call
Tools->>Agent: Search results + sources
Agent->>Agent: Update context with sources
else Tool: AdaptPlan
Agent->>Tools: Execute plan adaptation
Tools->>Agent: Updated research plan
else Tool: CreateReport
Agent->>Tools: Execute report creation
Tools->>Tools: Generate comprehensive<br/>report with citations
Tools->>Agent: Final research report
else Tool: ReportCompletion
Note over Agent: State: COMPLETED
Agent->>Tools: Execute completion
Tools->>Agent: Task completion status
end
Agent->>Agent: Add tool result to<br/>conversation history
API-->>Client: Stream tool execution result
break Task Completed
Agent->>Agent: Break execution loop
end
end
Agent->>API: Finish streaming
API-->>Client: Close SSE stream
Note over Client, Tools: Agent remains accessible<br/>via agent_id for further clarifications
- π€ Clarification - clarifying questions when unclear
- π Plan Generation - research plan creation
- π Web Search - internet information search
- π Plan Adaptation - plan adaptation based on results
- π Report Creation - detailed report creation
- β Completion - task completion
| Agent | SGR Implementation | ReasoningTool | Tools | API Requests | Selection Mechanism |
|---|---|---|---|---|---|
| 1. SGR-Agent | Structured Output | β Built into schema | 6 basic | 1 | SO Union Type |
| 2. FCAgent | β Absent | β Absent | 6 basic | 1 | FC "required" |
| 3. HybridSGRAgent | FC Tool enforced | β First step FC | 7 (6 + ReasoningTool) | 2 | FC β FC TOP AGENT |
| 4. OptionalSGRAgent | FC Tool optional | β At modelβs choice | 7 (6 + ReasoningTool) | 1β2 | FC "auto" |
| 5. ReasoningFC_SO | FC β SO β FC auto | β FC enforced | 7 (6 + ReasoningTool) | 3 | FC β SO β FC auto |
2025 // vamplab