aswyga/agent_bench
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
AI Benchmark Agent
A streamlined, multi-tool AI agent optimized for passing AI benchmarks like GAIA. Built with LangChain and LangGraph, featuring essential tools for information retrieval, code execution, and mathematical operations.
๐ Features
- Multi-language Code Execution: Python, Bash, SQL, C, Java
- Information Retrieval: Web search and Wikipedia lookup
- Mathematical Operations: Basic arithmetic, powers, roots, modulus
- File Processing: CSV/Excel analysis, file operations
- Optimized for Benchmarks: Focused toolset for maximum performance
๐ Base Configuration
Environment Variables
Create a .env file in the project root with the following variables:
# Required: OpenAI API Key (for GPT-4o-mini)
OPENAI_API_KEY=your_openai_api_key_here
# Optional: Additional API Keys
TAVILY_API_KEY=your_tavily_api_key_here # For web search
GROQ_API_KEY=your_groq_api_key_here # Alternative LLM provider
# Hugging Face Space Configuration
SPACE_ID=agent_bench # Your Hugging Face space ID
# Optional: Vector Store (not needed for basic benchmarks)
SUPABASE_URL=your_supabase_url_here
SUPABASE_KEY=your_supabase_key_hereModel Configuration
The agent is configured to use GPT-4o-mini by default for optimal performance:
# In agent.py
DEFAULT_PROVIDER = "openai"
OPENAI_MODEL = "gpt-4o-mini"๐ Hugging Face Spaces Configuration
The configuration above (at the top of this file) is what Hugging Face Spaces uses to configure your space.
Configuration Details:
- Title: AI Benchmark Agent
- Emoji: ๐ง (brain for AI intelligence)
- Colors: Blue to purple gradient (professional AI theme)
- SDK: Gradio for the web interface
- App File:
app.py(our main evaluation application) - Pinned: false (won't appear in pinned spaces)
๐ ๏ธ Installation
- Clone the repository:
git clone <your-repo-url>
cd agent_bench- Create virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set environment variables:
export OPENAI_API_KEY="your_actual_openai_api_key"
export SPACE_ID="agent_bench"๐ฏ Usage
Running the Evaluation App
source venv/bin/activate
export SPACE_ID="agent_bench"
python app.pyAccess the Gradio interface at: http://127.0.0.1:7860
Testing Individual Components
# Test agent imports
python -c "from agent import build_graph; print('โ
Agent ready')"
# Test code interpreter
python -c "from code_interpreter import CodeInterpreter; print('โ
Code interpreter ready')"๐ง Core Components
Agent Tools
Essential Tools (Optimized for Benchmarks):
web_search: Tavily web search (3 results max)wiki_search: Wikipedia search (2 results max)execute_code_multilang: Multi-language code executionadd,subtract,multiply,divide: Basic mathpower,square_root,modulus: Advanced mathsave_and_read_file: File operationsdownload_file_from_url: URL downloadsanalyze_csv_file: CSV analysisanalyze_excel_file: Excel analysis
Removed (Unnecessary for Benchmarks):
- Image processing tools (OCR, transformations, drawing)
- Vector store retrieval
- Arxiv search
- Complex plotting capabilities
Code Interpreter
Supports execution of:
- Python: With pandas, math, statistics libraries
- Bash: Shell commands with timeout
- SQL: SQLite queries with DataFrame output
- C: GCC compilation and execution
- Java: Javac compilation and execution
๐ Performance Targets
- Startup Time: < 5 seconds
- Tool Response: < 2 seconds per tool
- Code Execution: < 30 seconds timeout
- Memory Usage: < 500MB RAM
๐จ System Prompt Strategy
The agent uses a focused system prompt optimized for benchmark questions:
You are a helpful assistant tasked with answering questions using a set of tools.
Now, I will ask you a question. Report your thoughts, and finish your answer with the following template:
FINAL ANSWER: [YOUR FINAL ANSWER].
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.๐ Security & Safety
- Code Execution: Sandboxed environment with timeout limits
- Module Restrictions: Limited to essential Python modules
- File Operations: Restricted to working directory
- Network Access: Controlled through specific tools only
๐จ Troubleshooting
Common Issues
- "api_key client option must be set"
- Set
OPENAI_API_KEYenvironment variable - Ensure API key is valid and has credits
- "ModuleNotFoundError"
- Activate virtual environment:
source venv/bin/activate - Reinstall dependencies:
pip install -r requirements.txt
- "SPACE_ID environment variable not found"
- Set
export SPACE_ID="agent_bench" - Or add to your
.envfile
- Tool execution errors
- Check tool-specific API keys (TAVILYAPIKEY for web search)
- Verify internet connection for web tools
Performance Optimization
- Use GPT-4o-mini for best cost/performance ratio
- Keep only essential tools loaded
- Monitor memory usage during long sessions
- Restart agent if memory usage exceeds 500MB
๐ Benchmark Results
The agent is designed to achieve high scores on:
- GAIA Benchmark: Factual question answering
- Mathematical Reasoning: Arithmetic and logic problems
- Code Execution: Multi-language programming tasks
- Information Retrieval: Web and knowledge base queries
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make minimal, focused changes
- Test thoroughly with benchmark questions
- Submit pull request with clear description
Note: This agent is optimized for AI benchmark performance. For production use, consider additional security measures and error handling.
