Looplit is an unopinionated Agent Studio.
looplit.mp4
In the current landscape, much of the community's focus is on Agent frameworks.
Looplit's thesis is that orchestration should primarily be handled by the LLM (think LLM + tools + while loop).
Developers don't need yet another framework but rather tooling to debug, replay, and interact with Agents effectively.
Looplit is designed for developers who:
- Spend time tuning prompts and tool definitions to improve agents
- Need to replay and debug agents using production traces
- An orchestration framework
- A memory management system
- An LLM library
- 💬 Message-Based UI: Interact seamlessly with an Agent.
⤵️ State Fork: Create branches in your agent's state.- ⏱️ Time Travel: Navigate through different states in time.
- 💾 Save/Upload States: Persist and share agent states.
Looplit's time travel and forking capabilities rely on a state-in, state-out pattern. Your agent function should be structured as follows:
import looplit as ll
init_state = ll.State()
@ll.stateful(init_state=init_state)
def my_agentic_function(state: ll.State) -> ll.State:
# ... agentic work here
state.messages.append({
"role": "assistant",
"content": "My super smart agent response"})
return state
The @ll.stateful
decorator makes Looplit aware of your function. If the code isn't run with the looplit
command, it will simply return the original function.
The ll.State class is a straightforward Pydantic model. Each function invocation takes the previous state and returns a new one.
from pydantic import BaseModel, Field
class State(BaseModel):
# This field is handled by Looplit
id: str = Field(default_factory=lambda: str(uuid4()))
# Messages HAVE to follow the OpenAI schema for now
messages: List[Any] = Field(default_factory=list)
tools: Optional[List[Any]] = None
You can and should extend this class to include any relevant information your agent needs.
Note: The
ll.State
class must be JSON serializable.
Install the latest version:
Note: The package is not released yet. You will need
pnpm
to build locally.
pip install git+https://github.com/willydouhard/looplit.git#subdirectory=backend/
Start the Agent Studio:
looplit my_agent.py
Where my_agent.py
is the file containing your @ll.stateful
decorated functions.
The looplit
command will start a FastAPI server serving your agentic functions and exposing the Studio UI on http://localhost:8000.
Looplit doesn't dictate how you should code your agent, but here are two simple examples showcasing a router agent capable of calling another agent:
The examples above demonstrate a common pattern involving a router Agent that can call other Agents through tools. Looplit supports this pattern provided:
- The sub-agent is decorated with
@ll.stateful
. - The tool call name follows the
call_{sub_agent_function_name}
convention.
looplit-canvas.mp4
Looplit make it easy to leverage LLMs to iterate on your system prompt/tool definitions:
- Click on the ✨ button below the faulty assistant/tool message
- Type a message describing the issue
Note: The implementation uses
gpt-4o
. All of the logic is located in the canvas.py file.
This will open the canvas and suggest editions you can accept/reject (similarly to the conflict resolver UI of VsCode).
- AI enabled iteration/debugging
- Voice Support
We believe that Agents are essentially while loops (or recursions) + llm + tools. Looplit is created by the authors of Chainlit and Literal AI.
Feel free to contribute, raise issues, or suggest improvements. Happy coding! 🚀