Drop agent() anywhere in your code to execute agentic workflows — as easy as print()
Project description
█▀▀ █▀█ █▄ █ █▀ █▀█ █ █▀▀
█▄▄ █▄█ █ ▀█ ▄█ █▄█ █▄▄ ██▄
.agent
agent("debug this")— as easy asprint()
Drop agent() anywhere in your Python code to execute agentic AI workflows. Powered by Google Gemini & Ollama via Agno.
⚡ Quick Start
pip install console-agent
from console_agent import agent, init
# Optional: configure (works with sensible defaults + GEMINI_API_KEY env var)
init(api_key="your-key", model="gemini-2.5-flash-lite")
# Fire-and-forget — just like print()
agent("analyze this error", context=error)
# Get structured results
result = agent("validate email format", context=email, mode="blocking")
print(result.summary)
print(result.confidence)
🎭 Persona Shortcuts
Each persona has a specialized system prompt optimized for its domain:
# 🛡️ Security audit
agent.security("audit this SQL query", context=query)
# 🐛 Debug analysis
agent.debug("investigate slow query", context={"duration": dur, "sql": sql})
# 🏗️ Architecture review
agent.architect("review API design", context=endpoint)
Personas are auto-detected from prompt keywords, or you can force one:
agent("analyze this code", persona="security")
🔄 Async Support
# Native async
result = await agent.arun("analyze this", context=data)
# Works in Jupyter notebooks too!
🔌 Providers
Google Gemini (default)
Cloud-hosted, full tool support, API key required.
from console_agent import init
init(
provider="google", # default
api_key="...", # or set GEMINI_API_KEY env var
model="gemini-2.5-flash-lite", # default model
)
Ollama (Local Models)
Run models locally with Ollama. Free, private, no API key needed.
# 1. Install Ollama: https://ollama.com
# 2. Pull a model
ollama pull llama3.2
from console_agent import init
init(
provider="ollama",
model="llama3.2", # any model from `ollama list`
ollama_host="http://localhost:11434", # default
)
Provider Comparison
| Google Gemini | Ollama | |
|---|---|---|
| Setup | GEMINI_API_KEY env var |
Install Ollama + pull model |
| Config | provider="google" |
provider="ollama" |
| Models | gemini-2.5-flash-lite, etc. |
llama3.2, any ollama list model |
| Tools | ✅ google_search, code_execution, url_context | ❌ Not supported |
| Thinking | ✅ Supported | ❌ Not supported |
| File attachments | ✅ Full support | ⚠️ Text-only |
| Cost | Pay per token (very cheap) | Free (local) |
| Privacy | Cloud (with anonymization) | 100% local |
⚙️ Configuration
from console_agent import init
init(
provider="google", # "google" | "ollama"
api_key="...", # or set GEMINI_API_KEY env var
model="gemini-2.5-flash-lite", # default model
ollama_host="http://localhost:11434", # Ollama host (when provider="ollama")
persona="general", # default persona
mode="fire-and-forget", # or "blocking"
timeout=10000, # ms before timeout
anonymize=True, # auto-strip secrets/PII
dry_run=False, # log without calling API
log_level="info", # silent | errors | info | debug
budget={
"max_calls_per_day": 100,
"max_tokens_per_call": 8000,
"cost_cap_daily": 1.0,
},
)
📊 Structured Output
Get typed responses using Pydantic models:
from pydantic import BaseModel
class CodeReview(BaseModel):
issues: list[str]
severity: str
suggestion: str
result = agent(
"review this function",
context=code,
schema_model=CodeReview,
)
# result.data is a dict matching CodeReview fields
🔒 Built-in Safety
- PII/Secret anonymization — auto-strips API keys, emails, IPs, tokens before sending
- Rate limiting — token bucket algorithm prevents abuse
- Budget tracking — daily call limits, token caps, and cost caps
- Dry run mode — log prompts without making API calls
🧪 Testing
# Install dev dependencies
pip install -e ".[dev]"
# Run unit tests
pytest tests/unit/ -v
# Run integration tests (dry run, no API key needed)
pytest tests/integration/ -v
# Run e2e tests (requires GEMINI_API_KEY)
GEMINI_API_KEY=your-key pytest tests/e2e/ -v
📦 Architecture
console_agent/
├── __init__.py # Public API: agent(), init()
├── types.py # Pydantic models (AgentResult, AgentConfig, etc.)
├── core.py # Agent engine (orchestration, budget, rate-limit)
├── personas/ # Specialized AI personas
│ ├── general.py # 🔍 General-purpose
│ ├── debugger.py # 🐛 Error analysis
│ ├── security.py # �️ Security audit
│ └── architect.py # 🏗️ Architecture review
├── providers/
│ ├── google.py # Agno + Gemini integration
│ └── ollama.py # Agno + Ollama integration (local models)
├── utils/
│ ├── anonymize.py # PII/secret stripping
│ ├── rate_limit.py # Token bucket rate limiter
│ ├── budget.py # Daily budget tracker
│ └── format.py # Rich console output
└── tools/
├── code_execution.py
├── search.py
└── file_analysis.py
🔗 Also Available
- Node.js:
@console-agent/agent - Docs: console-agent.github.io
- GitHub: github.com/console-agent
License
MIT © Console Agent
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
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 console_agent-1.2.3.tar.gz.
File metadata
- Download URL: console_agent-1.2.3.tar.gz
- Upload date:
- Size: 56.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63e3dda602d82e60adb2f749ce9a1712446f242d855b7ebebc694147adeddedd
|
|
| MD5 |
b4f9ce662f1a12b32998b4ae8e91a70c
|
|
| BLAKE2b-256 |
1a3264f9d3bc04a3bce8bd359f4f238f7f83b9f4415baf1c37a6bd4d888d4fe2
|
File details
Details for the file console_agent-1.2.3-py3-none-any.whl.
File metadata
- Download URL: console_agent-1.2.3-py3-none-any.whl
- Upload date:
- Size: 37.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f64f314a07f800c6cdc4972c67026252a385a9b6ee8051e1b2e6fd158e50d8de
|
|
| MD5 |
f430d64a3ea4d172306ccf600d0bce1a
|
|
| BLAKE2b-256 |
35672c826ca2e905aaa2f460d46c97aa06fdb111ebb34e1f4466a820ed383d5b
|