@@ -121,6 +121,81 @@ Run:
121121swift run MinimalAgentDemo
122122```
123123
124+ ## Agent Loop Architecture
125+
126+ ### System Structure (Modules + External Interactions)
127+
128+ ``` mermaid
129+ flowchart TB
130+ subgraph HostApp["Host App (CLI / iOS / macOS)"]
131+ direction LR
132+ UI["App UI / CLI Entry"]
133+ Confirm["Confirmation Handler"]
134+ AppTools["App-defined AgentTool(s)"]
135+ SkillDir["Local skills directory (.md/.markdown)"]
136+ end
137+
138+ subgraph SwiftAgentCore["SwiftAgentCore"]
139+ direction TB
140+
141+ subgraph Core["Core"]
142+ direction LR
143+ Loop["runAgentLoop"]
144+ Registry["ToolRegistry"]
145+ Types["AgentLoopConfig / AgentEvent / LLMMessage"]
146+ end
147+
148+ subgraph Skills["Skills"]
149+ direction LR
150+ Loader["SkillLoader"]
151+ Defs["SkillDefinition"]
152+ end
153+
154+ subgraph LLM["LLM Layer"]
155+ direction LR
156+ Proto["LLMProvider protocol"]
157+ OAI["OpenAICompatibleProvider"]
158+ Resp["OpenAIResponsesProvider"]
159+ Gem["GeminiProvider"]
160+ Mini["MiniMaxAnthropicProvider"]
161+ Fallback["StructuredToolFallbackProvider"]
162+ OAuth["OAuth helpers + callback server"]
163+ end
164+ end
165+
166+ subgraph External["External Systems"]
167+ direction LR
168+ OpenAI["OpenAI-compatible APIs"]
169+ GeminiAPI["Google Gemini API"]
170+ MiniMaxAPI["MiniMax Anthropic-compatible API"]
171+ Browser["System Browser (OAuth)"]
172+ Callback["Local OAuth Callback Endpoint"]
173+ end
174+
175+ UI --> Loop
176+ Confirm --> Loop
177+ AppTools --> Registry
178+ SkillDir --> Loader --> Defs
179+
180+ Loop --> Registry
181+ Loop --> Types
182+ Loop --> Proto
183+ Proto --> OAI
184+ Proto --> Resp
185+ Proto --> Gem
186+ Proto --> Mini
187+ Proto --> Fallback
188+ Resp --> OAuth
189+
190+ OAI --> OpenAI
191+ Resp --> OpenAI
192+ Gem --> GeminiAPI
193+ Mini --> MiniMaxAPI
194+ OAuth --> Browser
195+ Browser --> Callback
196+ Callback --> OAuth
197+ ```
198+
124199## Provider Examples
125200
126201### OpenAI-compatible
@@ -188,7 +263,7 @@ It does **not** include persistent state storage, database session management, o
188263The next minor release focuses on interview-ready onboarding and stronger runtime validation:
189264
190265- [x] Add ` Examples/ ` minimal runnable demo (CLI-first) that can be verified in ~ 3 minutes.
191- - [ ] Add an Agent loop architecture diagram to this README (message/tool/confirmation flow).
266+ - [x ] Add an Agent loop architecture diagram to this README (message/tool/confirmation flow).
192267- [x] Add core tests for ` AgentLoop ` and ` SkillLoader ` to balance existing provider-heavy coverage.
193268- [ ] Add clearer memory/context guidance and APIs for session-level context management.
194269
0 commit comments