Skip to main content

Smart AI agents that think as hard as they need to.

Project description

Cogency

PyPI version License Python 3.10+

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

Preprocess → Reason → Act → Respond

👤 Plan a Tokyo trip with $2000 budget

🔧 Tools: weather, calculator, search
🧠 Task complexity → escalating to Deep React
🌤️ weather(Tokyo) → 25°C sunny, rain Thu-Fri
🧮 calculator($2000 ÷ 5 days) → $400/day
🔍 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 preprocessing 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:

🧮 Calculator - Mathematical expressions and calculations
🔍 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

📄 License

Apache 2.0 - Build whatever you want.

Beta Feedback

We're actively gathering feedback from early adopters:


Built for developers who want agents that just work, not frameworks that require PhD-level configuration.

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

cogency-0.9.2.tar.gz (94.8 kB view details)

Uploaded Source

Built Distribution

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

cogency-0.9.2-py3-none-any.whl (131.8 kB view details)

Uploaded Python 3

File details

Details for the file cogency-0.9.2.tar.gz.

File metadata

  • Download URL: cogency-0.9.2.tar.gz
  • Upload date:
  • Size: 94.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.10 Darwin/24.5.0

File hashes

Hashes for cogency-0.9.2.tar.gz
Algorithm Hash digest
SHA256 8171021eddea823ebe0386626b151b241061452391036c902c0fa7801b08f088
MD5 ad6fa200bceccd45d8aa8b6494c7a4f6
BLAKE2b-256 ded4ce3f0e9d28dd2de0634c520570db6e926db51cdf28b96de2eb96cd6e2155

See more details on using hashes here.

File details

Details for the file cogency-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: cogency-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 131.8 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

Hashes for cogency-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5337471b14502c03e07ac08be352b40f3bcbdc435c26f96fc5fa9aea27ed4dbc
MD5 59691e451c17dea3a5c23bb91ae20c62
BLAKE2b-256 cc92742f4ea9b55824f8b142025e50785a00b67148ed976f5c1e24ad6365a29a

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