flowchart TD
POST[Request to /] --> POST2[Parse Body]
POST2 --> |JSON| POST3[Start Agent Session -- Message mode]
POST3 --> POST4[Pass Initial Message to Agent]
POST4 --> C[Create Client With Initial Message in History]
C --> D[Wait for Response]
E[For Every Content Block in Msg]
E1[Add To History]
D --> |Message Received| E1
E1 --> E
E --> F{Is tool_use?}
F --> |Yes| G[Run Tool Function]
F --> |No| I
G --> |Tool Result| I[Add to Content Block]
I --> I1[Done Parsing]
I1 --> |Send Parsed Message to Server| J[Send Payload as Response]
GET[Request to /] --> Agent[Get List Available Agents]
Agent --> |JSON| GET2[Response with List of Agents]