Codinainteasy commited on
Commit
2ad8730
Β·
verified Β·
1 Parent(s): a0d04ac

Create Looplens

Browse files

"A living benchmark for agent reasoning"

Files changed (1) hide show
  1. Looplens +88 -0
Looplens ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ space-link/
2
+ β”œβ”€β”€ app.py # Gradio app with streaming traces
3
+ β”œβ”€β”€ requirements.txt # Dependencies
4
+ β”œβ”€β”€ README.md # Full docs
5
+ β”œβ”€β”€ .gitignore
6
+ β”‚
7
+ β”œβ”€β”€ agents/
8
+ β”‚ β”œβ”€β”€ __init__.py
9
+ β”‚ β”œβ”€β”€ loops/
10
+ β”‚ β”‚ β”œβ”€β”€ base.py # Abstract base: BaseAgentLoop, BaseMemory, Tool
11
+ β”‚ β”‚ β”œβ”€β”€ react_loop.py # ReAct: Thought β†’ Action β†’ Observation
12
+ β”‚ β”‚ β”œβ”€β”€ plan_execute_loop.py # Plan β†’ Execute β†’ Synthesize
13
+ β”‚ β”‚ └── reflection_loop.py # Action β†’ Reflection β†’ Refinement
14
+ β”‚ β”œβ”€β”€ tools/
15
+ β”‚ β”‚ β”œβ”€β”€ web_search.py # Simulated search with keyword routing
16
+ β”‚ β”‚ └── calculator.py # Safe math eval + demo cases
17
+ β”‚ └── memory/
18
+ β”‚ └── short_term.py # Sliding-window context memory
19
+ β”‚
20
+ β”œβ”€β”€ config/
21
+ β”‚ └── settings.py # AgentConfig & SpaceConfig dataclasses
22
+ β”œβ”€β”€ ui/ # Expansion-ready UI package
23
+ └── tests/
24
+ └── test_loops.py # pytest suite for all loops & tools
25
+ from agents.loops.react_loop import ReActAgent
26
+ from agents.tools.web_search import WebSearchTool
27
+ from agents.tools.calculator import CalculatorTool
28
+ from agents.memory.short_term import ShortTermMemory
29
+
30
+ agent = ReActAgent(
31
+ tools=[WebSearchTool(), CalculatorTool()],
32
+ memory=ShortTermMemory(max_items=10),
33
+ max_steps=5
34
+ )
35
+ result = agent.run("What is the population of Tokyo divided by Paris?")
36
+ from agents.loops.plan_execute_loop import PlanExecuteAgent
37
+
38
+ agent = PlanExecuteAgent(
39
+ tools=[WebSearchTool(), CalculatorTool()],
40
+ memory=ShortTermMemory(max_items=10),
41
+ max_steps=5
42
+ )
43
+ from agents.loops.reflection_loop import ReflectionAgent
44
+
45
+ agent = ReflectionAgent(
46
+ tools=[WebSearchTool(), CalculatorTool()],
47
+ memory=ShortTermMemory(max_items=10),
48
+ max_steps=5
49
+ )
50
+ Tab Function
51
+ ▢️ Single Run Pick a loop architecture, set max steps, and watch the real-time execution trace with color-coded steps (🧠 Thought, πŸ”§ Action, πŸ‘οΈ Observation, βœ… Final)
52
+ βš–οΈ Compare All Loops Run the same query across all three architectures side-by-side with step counts and timing
53
+ πŸ“š Architecture Guide Built-in documentation explaining when to use each loop
54
+ pytest tests/ -v
55
+ gradio>=4.0.0
56
+ pydantic>=2.0.0
57
+ python-dotenv>=1.0.0
58
+ pytest>=7.0.0
59
+ πŸ”Œ Extending the Architecture
60
+ Because every loop inherits from BaseAgentLoop , adding a new architecture (like Tree of Thoughts or DSPy) requires only:
61
+ 1.
62
+ Subclass BaseAgentLoop
63
+ 2.
64
+ Implement run() and run_stream()
65
+ 3.
66
+ Register it in app.py 's AGENTS dictionary
67
+ The UI, comparison logic, and memory systems work automatically.
68
+ The full codebase is saved in /mnt/agents/output/space-link/ . You can zip it, push it to a Hugging Face Space, or extend it with a real LLM backend by swapping the _think() methods for actual OpenAI/Claude/local model calls.MIT License
69
+
70
+ Copyright (c) 2026 Roger Lawson
71
+
72
+ Permission is hereby granted, free of charge, to any person obtaining a copy
73
+ of this software and associated documentation files (the "Software"), to deal
74
+ in the Software without restriction, including without limitation the rights
75
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
76
+ copies of the Software, and to permit persons to whom the Software is
77
+ furnished to do so, subject to the following conditions:
78
+
79
+ The above copyright notice and this permission notice shall be included in all
80
+ copies or substantial portions of the Software.
81
+
82
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
83
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
84
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
85
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
86
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
87
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
88
+ SOFTWARE.