Smart AI agents that think as hard as they need to.
Project description
Cogency
Smart AI agents that think as hard as they need to.
🚧 Production Beta (v0.9.1) - Architecturally complete, actively gathering feedback from early adopters. Ready for serious evaluation and beta deployments.
from cogency import Agent
agent = Agent("assistant")
# Simple task → thinks fast
await agent.run("What's 2+2?")
# Complex task → thinks deep
await agent.run("Analyze this codebase and suggest architectural improvements")
# Automatically escalates reasoning, uses relevant tools, streams thinking
🧠 Adaptive Reasoning
Thinks fast or deep as needed - agents discover task complexity during execution and adapt their cognitive approach automatically.
- Fast React: Direct execution for simple queries
- Deep React: Reflection + planning for complex analysis
- Zero-cost switching: Seamless transitions preserve full context
- Runtime discovery: No upfront classification - intelligence governs intelligence
🚀 Key Features
- 🤖 Agents in 3 lines - Fully functional, tool-using agents from a single import
- 🔥 Adaptive reasoning - Thinks fast or deep as needed, switches seamlessly during execution
- 🌊 Streaming first - Watch agents think in real-time with full transparency
- 🛠️ Automatic tool discovery - Drop tools in, they auto-register and route intelligently
- ⚡️ Zero configuration - Auto-detects LLMs, tools, memory from environment (fast models by default)
- 🧠 Built-in memory - Persistent memory with extensible backends (Pinecone, ChromaDB, PGVector)
- ✨ Clean tracing - Every reasoning step traced and streamed with clear phase indicators
- 🌍 Universal LLM support - OpenAI, Anthropic, Gemini, Grok, Mistral out of the box
- 🧩 Extensible design - Add tools, memory backends, embedders with zero friction
- 👥 Multi-tenancy - Built-in user contexts and conversation isolation
- 🏗️ Production hardened - Resilience, rate limiting, metrics, tracing included
How It Works
Prepare → Reason → Act → Respond
👤 Plan a Tokyo trip with $2000 budget
🔧 Tools: code, search
🧠 Task complexity → escalating to Deep React
🌤️ weather(Tokyo) → 25°C sunny, rain Thu-Fri
🧮 code(print(2000 / 5)) → 400.0
🔍 search(Tokyo indoor activities) → Museums, temples
💭 Reflection: Need indoor backup plans for rainy days
📋 Planning: 5-day itinerary with weather contingencies
🤖 Here's your optimized Tokyo itinerary...
The preparing phase handles tool selection, memory operations, and intelligent routing between reasoning modes.
Quick Examples
Custom Tools
from cogency.tools import Tool, tool
@tool
class MyTool(Tool):
def __init__(self):
super().__init__("my_tool", "Does something useful")
async def run(self, param: str):
return {"result": f"Processed: {param}"}
# Tool auto-registers - just create agent
agent = Agent("assistant")
await agent.run("Use my_tool with hello")
Real-World Applications
# Research Agent
agent = Agent("researcher")
await agent.run("Latest quantum computing developments?")
# Coding Assistant
agent = Agent("coder")
await agent.run("Fix the auth bug in this Flask app")
# Data Analyst
agent = Agent("analyst")
await agent.run("Analyze sales trends in quarterly_data.csv")
Built-in Tools
Agents automatically discover and use relevant tools:
💻 Code - Execute Python code
🔍 Search - Web search for current information
🌤️ Weather - Current conditions and forecasts
📁 Files - Create, read, edit, list, delete files
💻 Shell - Execute system commands safely
🐍 Code - Python code execution in sandboxed environment
📊 CSV - Data processing and analysis
🗄️ SQL - Database querying and management
🌐 HTTP - Make HTTP requests with JSON parsing
🕒 Time - Date/time operations and timezone conversions
🔗 Scrape - Web scraping with content extraction
🧠 Recall - Memory search and retrieval
Installation
pip install cogency
Beta Note: Cross-provider testing is ongoing. OpenAI and Anthropic are well-tested; other providers may have edge cases.
Set any LLM API key:
export OPENAI_API_KEY=... # or
export ANTHROPIC_API_KEY=... # or
export GEMINI_API_KEY=... # etc
Documentation
- Quick Start - Get running in 5 minutes
- API Reference - Complete Agent class documentation
- Tools - Built-in tools and custom tool creation
- Examples - Detailed code examples and walkthroughs
- Memory - Memory backends and configuration
- Reasoning - Adaptive reasoning modes
- Configuration - Advanced configuration options
- Troubleshooting - Common issues and solutions
📄 License
Apache 2.0 - Build whatever you want.
Beta Feedback
We're actively gathering feedback from early adopters:
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Known limitations: Cross-provider behavior, memory backend edge cases
Built for developers who want agents that just work, not frameworks that require PhD-level configuration.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cogency-0.9.3.tar.gz.
File metadata
- Download URL: cogency-0.9.3.tar.gz
- Upload date:
- Size: 74.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.10 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64672315b3cb5dd708d3ec02209068544ea2fe883d833f9750b1c915d7598b6d
|
|
| MD5 |
55b97ff274ff78e406568fcc72b0b4e8
|
|
| BLAKE2b-256 |
cf8d6cad0d21de7174098f5e4b13f61d172f0657aaf73b12468a9a613f955788
|
File details
Details for the file cogency-0.9.3-py3-none-any.whl.
File metadata
- Download URL: cogency-0.9.3-py3-none-any.whl
- Upload date:
- Size: 104.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.10 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bb6682820eb4fd21cfcfef0f7118b070ab18aa1a2d1ed1a974f7e09b1bb41d2
|
|
| MD5 |
a903cc183543692e6d811bc649d1c98e
|
|
| BLAKE2b-256 |
97dabaa3bf709c52c5290ef47193025d128022a341fc1c409b2cdb616909ff6f
|