Please join our discord for support: Discord
TFrameX empowers you to build sophisticated, multi-agent LLM applications with unparalleled ease and flexibility. Move beyond simple prompt-response interactions and construct complex, dynamic workflows where intelligent agents collaborate, use tools, and adapt to intricate tasks.
streaming=TruePerfect for production deployments, enterprise applications, and mission-critical AI systems!
Find our Agent Builder Framework Here: Tesslate Studio Agent Builder
🧠 Intelligent Agents, Simplified: Define specialized agents with unique system prompts, tools, and even dedicated LLM models.
🛠️ Seamless Tool Integration: Equip your agents with custom tools using a simple decorator. Let them interact with APIs, databases, or any Python function.
🌊 Powerful Flow Orchestration: Design complex workflows by chaining agents and predefined patterns (Sequential, Parallel, Router, Discussion) using an intuitive Flow API.
⚡ Lightning-Fast Streaming: Experience real-time agent responses with our revolutionary streaming support - just add streaming=True for instant responsiveness.
🔌 Universal MCP Connectivity: Connect to any MCP-compatible service with zero friction - from file systems to databases to external APIs.
🧩 Composable & Modular: Build reusable components (agents, tools, flows) that can be combined to create increasingly complex applications.
🚀 Agent-as-Tool Paradigm: Elevate your architecture by enabling agents to call other agents as tools, creating hierarchical and supervised agent structures.
🏢 Enterprise-Ready: Full RBAC, authentication, audit logging, metrics collection, and multi-backend storage for production deployments.
🎨 Fine-Grained Control: Customize agent behavior with features like per-agent LLMs and <think> tag stripping for cleaner outputs.
💬 Interactive Debugging: Quickly test your flows and agents with the built-in interactive chat.
🔌 Pluggable LLMs: Start with OpenAIChatLLM (compatible with OpenAI API and many local server UIs like Ollama) and extend to other models easily.
⚡ CLI Tooling: Complete command-line interface with tframex basic for instant interaction, tframex setup for project scaffolding, and tframex serve for web interfaces.
TFrameX is designed to orchestrate complex agent interactions using its powerful Flow system, which controls the sequence and logic of operations.
Within a Flow, you define reusable collaboration structures called Patterns—such as SequentialPattern, RouterPattern, or DiscussionPattern. These patterns can be nested inside one another. For example, a ParallelPattern may contain several SequentialPatterns, enabling hierarchical task breakdowns.
TFrameX also supports the agent-as-tool paradigm: LLMAgents can directly call other registered agents. This enables supervisor-worker relationships and task delegation between agents.
Together, nested patterns and inter-agent calling allow for sophisticated designs—including recursive or cyclical flows. For example, a DiscussionPattern creates a controlled loop of interaction. However, to avoid infinite loops, flows must be carefully structured with clear termination conditions or managed by moderator agents.
These entire Flows—along with their patterns and agent configurations—can be defined declaratively in YAML files. This makes it easy to version, share, and modify agent behaviors programmatically, giving you maximum flexibility in building adaptive, interconnected agent systems.
TFrameX revolves around a few key concepts:
🌟 Agents (BaseAgent, LLMAgent, ToolAgent):
The core actors in your system.
LLMAgent: Leverages an LLM to reason, respond, and decide when to use tools or call other agents.
ToolAgent: A stateless agent that directly executes a specific tool (useful for simpler, direct tool invocations within a flow).
Can have their own memory, system prompts, and a dedicated LLM instance.
Support for strip_think_tags: Automatically remove internal "thinking" steps (e.g., <think>...</think>) from the final output for cleaner user-facing responses.
🔧 Tools (@app.tool):
Python functions (sync or async) that agents can call to perform actions or retrieve information from the outside world (APIs, databases, file systems, etc.).
Schemas are automatically inferred from type hints or can be explicitly defined.
🌊 Flows (Flow):
Define the sequence or graph of operations.
A flow consists of steps, where each step can be an agent or a Pattern.
Orchestrate how data (as Message objects) and control pass between agents.
🧩 Patterns (SequentialPattern, ParallelPattern, RouterPattern, DiscussionPattern):
Reusable templates for common multi-agent interaction structures:
SequentialPattern: Executes a series of agents/patterns one after another.
ParallelPattern: Executes multiple agents/patterns concurrently on the same input.
RouterPattern: Uses a "router" agent to decide which subsequent agent/pattern to execute.
DiscussionPattern: Facilitates a multi-round discussion between several agents, optionally moderated.
🤝 Agent-as-Tool (Supervisor Agents):
A powerful feature where one LLMAgent can be configured to call other registered agents as if they were tools. This allows for creating supervisor agents that delegate tasks to specialized sub-agents.
🤖 LLMs (BaseLLMWrapper, OpenAIChatLLM):
Pluggable wrappers for LLM APIs. OpenAIChatLLM provides out-of-the-box support for OpenAI-compatible APIs (including many local model servers like Ollama or LiteLLM).
Agents can use a default LLM provided by the app, or have a specific LLM instance assigned for specialized tasks.
💾 Memory (InMemoryMemoryStore):
Provides agents with conversation history. InMemoryMemoryStore is available by default, and you can implement custom stores by inheriting from BaseMemoryStore.
The fastest way to get started with TFrameX is using the built-in CLI:
Install TFrameX:
bash
pip install tframex
Start an interactive session: ```bash # Set your API key export OPENAI_API_KEY="sk-..."
# Launch interactive chat tframex basic ```
# Configure environment cp .env.example .env # Edit .env with your API keys
# Install dependencies and run pip install -r requirements.txt python main.py ```
# Launch web server tframex serve # Open http://localhost:8000 in your browser ```
tframex basic - Interactive AI session with built-in toolstframex setup <project> - Complete project scaffolding tframex serve - Web interface for agent interactionFor complete CLI documentation, see CLI Guide and CLI Reference.
To use TFrameX in your project manually, install it via pip:
pip install tframex
Core dependencies (like httpx, pydantic, PyYAML, python-dotenv, openai) are listed in pyproject.toml and should be installed automatically. If you plan to run specific examples from the TFrameX repository, you might need additional packages like aiohttp (for the Reddit tool example) or Flask (for the web app example). You can install these separately: pip install aiohttp Flask.
**For Developers (Contributing to TFrameX or running all examples from source):**
If you're developing TFrameX itself or want to run examples directly from a cloned repository, we recommend setting up a dedicated virtual environment. You can use [`uv`](https://github.com/astral-sh/uv) for its speed, or `pip` with `venv`.
**Setting up with `uv` (Recommended):**
First, install `uv` by following the instructions at [astral.sh/uv](https://astral.sh/uv).
Then, in your cloned TFrameX repository:
```bash
# Clone the repository (if you haven't already)
# git clone https://github.com/TesslateAI/TFrameX.git
# cd TFrameX
# Create and activate a virtual environment
uv venv
source .venv/bin/activate # On macOS/Linux
# For Windows PowerShell: .venv\Scripts\Activate.ps1
# Install TFrameX in editable mode with optional dependencies
# For core development and running most examples:
uv pip install -e ".[examples]"
# To include development tools (linters, formatters):
# uv pip install -e ".[examples,dev]"
```
This approach uses the `pyproject.toml` file for precise dependency management.
**Setting up with `pip` and `venv` (Alternative):**
In your cloned TFrameX repository:
```bash
# Clone the repository (if you haven't already)
# git clone https://github.com/TesslateAI/TFrameX.git
# cd TFrameX
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On macOS/Linux
# For Windows Command Prompt: .venv\Scripts\activate.bat
# Install TFrameX in editable mode with optional dependencies
# For core development and running most examples:
pip install -e ".[examples]"
# To include development tools:
# pip install -e ".[examples,dev]"
```
Set up your LLM Environment:
Ensure your environment variables for your LLM API are set (e.g., OPENAI_API_KEY, OPENAI_API_BASE). Create a .env file in your project root (TFrameX uses python-dotenv to load this):
```env
# Example for Ollama (running locally)
OPENAI_API_BASE="http://localhost:11434/v1"
OPENAI_API_KEY="ollama" # Placeholder, as Ollama doesn't require a key by default
OPENAI_MODEL_NAME="llama3" # Or your preferred model served by Ollama
```
Your First TFrameX App:
```python import asyncio import os from dotenv import load_dotenv from tframex import TFrameXApp, OpenAIChatLLM, Message
load_dotenv() # Load .env file
my_llm = OpenAIChatLLM( model_name=os.getenv("OPENAI_MODEL_NAME", "gpt-3.5-turbo"), api_base_url=os.getenv("OPENAI_API_BASE"), # Can be http://localhost:11434/v1 for Ollama api_key=os.getenv("OPENAI_API_KEY") # Can be "ollama" for Ollama )
app = TFrameXApp(default_llm=my_llm)
@app.agent( name="GreeterAgent", system_prompt="You are a friendly greeter. Greet the user and mention their name: {user_name}." ) async def greeter_agent_func(): # The function body can be pass; TFrameX handles logic for LLMAgent pass
async def main(): async with app.run_context() as rt: # Creates a runtime context user_input = Message(role="user", content="Hello there!")
response = await rt.call_agent(
"GreeterAgent",
user_input,
# You can pass template variables to the system prompt
template_vars={"user_name": "Alex"}
)
print(f"GreeterAgent says: {response.content}")
if name == "main": # Basic check for LLM configuration if not my_llm.api_base_url: print(
$ claude mcp add TFrameX \
-- python -m otcore.mcp_server <graph>