Skip to main content

TAgent - Modular AI Agent Framework with Dynamic Tool Discovery

Project description

๐Ÿค– TAgent - Modular AI Agent Framework

Python 3.8+ License: MIT Code Style: Black

Build powerful AI agents with modular tools and automatic discovery

TAgent is a production-ready framework for creating AI agents with modular, reusable tools. It features automatic tool discovery, dynamic schema loading, and a powerful CLI for rapid development and deployment.

Built on LiteLLM - Universal LLM API for seamless integration with 100+ language models including OpenAI, Anthropic, Azure, Google, and local models.

โœจ Key Features

  • ๐Ÿ” Automatic Tool Discovery - Finds and loads tagent.tools.py files automatically
  • ๐Ÿ—๏ธ Modular Architecture - Reusable tools across different projects
  • ๐Ÿ“‹ Dynamic Schema Loading - Pydantic schemas from tagent.output.py files
  • ๐Ÿš€ Production CLI - Professional command-line interface with console scripts
  • ๐Ÿ”„ Intelligent Agent Loop - State machine-controlled adaptive planning, execution, and evaluation
  • ๐ŸŽฏ State Machine Control - Prevents infinite loops and enforces logical action sequences
  • ๐Ÿ› ๏ธ Rich Tool Ecosystem - Travel planning, e-commerce, and custom tools
  • ๐ŸŽฏ Type-Safe Output - Structured results with Pydantic validation
  • ๐Ÿ“ Comprehensive Logging - Beautiful retro-style terminal output

๐Ÿš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/Tavernari/tagent.git
cd tagent

# One-command setup (creates venv, installs everything)
make clean-install

# Activate virtual environment
source .venv/bin/activate

Basic Usage

# Test the CLI with built-in travel tools
tagent "Plan a trip from London to Rome for 2025-09-10 to 2025-09-17 with budget $2000" \
  --search-dir examples/travel_planning_cli \
  --max-iterations 10

# Quick discovery test
make cli-discovery-test

# See all available commands
make help

๐Ÿ“ Creating Your Own Tools

1. Create Tool Functions (myproject/tagent.tools.py)

from typing import Dict, Any, Tuple, Optional

def web_search_tool(state: Dict[str, Any], args: Dict[str, Any]) -> Optional[Tuple[str, Any]]:
    """Search the web for information."""
    query = args.get('query', '')
    
    # Your implementation here
    results = perform_web_search(query)
    
    return ('search_results', results)

def data_analysis_tool(state: Dict[str, Any], args: Dict[str, Any]) -> Optional[Tuple[str, Any]]:
    """Analyze data and generate insights."""
    data = args.get('data', [])
    
    # Your analysis logic
    insights = analyze_data(data)
    
    return ('analysis_insights', insights)

2. Define Output Schema (myproject/tagent.output.py)

from pydantic import BaseModel, Field
from typing import List

class ResearchReport(BaseModel):
    title: str = Field(..., description="Report title")
    summary: str = Field(..., description="Executive summary") 
    findings: List[str] = Field(default=[], description="Key findings")
    recommendations: List[str] = Field(default=[], description="Actionable recommendations")
    confidence_score: float = Field(..., description="Confidence in results (0-1)")

# Required variable name
output_schema = ResearchReport

3. Run Your Agent

tagent "Research the latest trends in AI and create a comprehensive report" \
  --search-dir myproject \
  --model openrouter/ollama/gemma3 \
  --verbose

๐ŸŽฏ Examples

Travel Planning Agent

# Complete travel itinerary with flights, hotels, activities
tagent "Plan a 7-day trip to Tokyo with cultural activities and budget $3000" \
  --search-dir examples/travel_planning_cli

E-commerce Analysis

# Business intelligence and product recommendations
tagent "Analyze customer data and suggest product improvements" \
  --search-dir examples/ecommerce \
  --model openrouter/ollama/gemma3

Custom Research

# Multi-source research with structured output
tagent "Research sustainable energy trends and create executive summary" \
  --tools ./research/tagent.tools.py \
  --output ./research/tagent.output.py

๐Ÿ› ๏ธ CLI Commands

Development Commands

make help                  # Show all commands
make install              # Install in virtual environment  
make clean-install        # Clean install (recommended)
make test                 # Run test suite
make lint                 # Code quality checks
make format               # Format code with black

CLI Commands

make cli-help             # Show CLI help
make cli-discovery-test   # Test tool discovery
make cli-test             # Full travel example
make cli-demo             # Generate demo GIF

# Direct CLI usage (after source .venv/bin/activate)
tagent --help
tagent "your goal" --search-dir path/to/tools

๐Ÿ—๏ธ Architecture

TAgent Framework
โ”œโ”€โ”€ ๐Ÿ” Tool Discovery Engine
โ”‚   โ”œโ”€โ”€ Automatic file scanning  
โ”‚   โ”œโ”€โ”€ Function signature validation
โ”‚   โ””โ”€โ”€ Dynamic imports
โ”œโ”€โ”€ ๐Ÿค– Intelligent Agent Core
โ”‚   โ”œโ”€โ”€ LLM-powered decision making (via LiteLLM)
โ”‚   โ”œโ”€โ”€ Adaptive planning
โ”‚   โ”œโ”€โ”€ Tool execution
โ”‚   โ””โ”€โ”€ Goal evaluation
โ”œโ”€โ”€ ๐Ÿ“‹ Schema Management
โ”‚   โ”œโ”€โ”€ Pydantic integration
โ”‚   โ”œโ”€โ”€ Type-safe outputs
โ”‚   โ””โ”€โ”€ Validation
โ””โ”€โ”€ ๐Ÿš€ Production CLI
    โ”œโ”€โ”€ Console scripts
    โ”œโ”€โ”€ Rich terminal UI
    โ””โ”€โ”€ Error handling

๐Ÿ”ง Core Dependencies

  • LiteLLM - Universal LLM integration supporting 100+ models
  • Pydantic - Type-safe data validation and schemas
  • Rich - Beautiful terminal UI and progress indicators

๐Ÿ“Š Built-in Tools

Travel Planning (examples/travel_planning_cli/)

  • โœˆ๏ธ Flight search with budget filtering
  • ๐Ÿจ Hotel recommendations with preferences
  • ๐ŸŽฏ Activity suggestions by interest
  • ๐Ÿ’ฐ Cost calculation and budgeting
  • ๐Ÿ“ Itinerary generation

E-commerce (examples/ecommerce/)

  • ๐Ÿ“ˆ Sales analysis and trends
  • ๐Ÿ‘ฅ Customer behavior insights
  • ๐Ÿ›๏ธ Product recommendations
  • ๐Ÿ’ก Business intelligence

๐Ÿ”ง Advanced Usage

Custom Models

# Use different LLM providers
tagent "goal" --model openrouter/google/gemma3
tagent "goal" --model openrouter/ollama/gemma3
tagent "goal" --model openrouter/openai/04-mini

For a complete list of supported models and integrations, please visit the LiteLLM Provider Documentation.

Multiple Tool Directories

# Search multiple directories
tagent "complex task" \
  --search-dir ./core-tools \
  --search-dir ./specialized-tools \
  --search-dir ./custom-tools \
  --recursive

API Configuration

# Set API key
export OPENAI_API_KEY="your-key"
# or
tagent "goal" --api-key your-key-here

๐ŸŽฌ Demo

Generate an animated demo:

make cli-demo  # Creates examples/tagent_cli_demo.gif

๐Ÿค Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Follow code style: make format && make lint
  4. Add tests: pytest tests/
  5. Commit changes: git commit -m "Add amazing feature"
  6. Push branch: git push origin feature/amazing-feature
  7. Open Pull Request

Development Setup

git clone https://github.com/Tavernari/tagent.git
cd tagent
make clean-install
source .venv/bin/activate
make test

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐ŸŒŸ Why TAgent?

  • ๐Ÿ”ฅ Rapid Development: Create agents in minutes, not hours
  • ๐Ÿ”ง Modular Design: Reuse tools across projects
  • ๐Ÿš€ Production Ready: Professional CLI and error handling
  • ๐ŸŽฏ Type Safety: Pydantic schemas ensure data integrity
  • ๐Ÿค– Intelligent: LLM-powered adaptive behavior
  • ๐Ÿ“ˆ Scalable: From prototypes to production systems

๐ŸŽ‰ Star History

If TAgent helps you build amazing AI agents, please give it a โญ!


Built with โค๏ธ for the AI community

๐Ÿ› Report Bug | โœจ Request Feature

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tagent-0.3.0.tar.gz (66.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tagent-0.3.0-py3-none-any.whl (42.0 kB view details)

Uploaded Python 3

File details

Details for the file tagent-0.3.0.tar.gz.

File metadata

  • Download URL: tagent-0.3.0.tar.gz
  • Upload date:
  • Size: 66.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for tagent-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a30f5dfe882b809f724dd338931b78e1008e389b63476ab8cd6fd729e72328ac
MD5 51a3e9ca790b27f9639e8064821e4d1f
BLAKE2b-256 2e1a2885a50f8ad84c9e7c0d618369e84addfa3a222fda72e71258eccfd7a41a

See more details on using hashes here.

File details

Details for the file tagent-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: tagent-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 42.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for tagent-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f05d80da050d1a2a021467aa3f5c64f8c2d6c2670f3a302294f95420dc6dd3a
MD5 22598117870771478bcc691c40cdb0ab
BLAKE2b-256 82f69e33ad884a77fc2760f4aae2b3f963b53be241fd4512e5eee61c7c0ab978

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page