From 43071f6950aa143d3d91ae62d9a65661904e73fe Mon Sep 17 00:00:00 2001 From: Sir Qasim Date: Mon, 19 May 2025 03:07:44 +0500 Subject: [PATCH] visualize the complete Agent Loop with an interactive UML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### 🤔 Why we need this The “Agent Loop” is the SDK’s most complex subsystem: 1. It spans \~2 000 lines across `run.py`, guardrails, hand-offs, and streaming helpers. 2. Contributors often ask *“Where do guardrails fire?”* or *“How does the Runner decide between tool-calls and hand-offs?”* A single picture out-ranks a thousand words; the diagram turns that spaghetti into a map: ``` Runner ──▶ Agent ──▶ Model ──▷ Response ▲ │ │ │ ▼ ▼ Guardrails ◀──┘ Tool-Calls / Handoffs ``` --- docs/running_agents.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/running_agents.md b/docs/running_agents.md index f631cf46..13da9b98 100644 --- a/docs/running_agents.md +++ b/docs/running_agents.md @@ -83,7 +83,9 @@ async def main(): print(result.final_output) # California ``` - +## Agent loop deep diagram +![image](https://github.com/user-attachments/assets/3b085816-6173-4fee-a936-5016e1c81755) +[Download PDF](https://github.com/panaversity/learn-agentic-ai/blob/main/01_ai_agents_first/15_run_lifecycle/Agent_loop.pdf) ## Exceptions The SDK raises exceptions in certain cases. The full list is in [`agents.exceptions`][]. As an overview: