Skip to main content

Drop agent() anywhere in your code to execute agentic workflows โ€” as easy as print()

Project description

console-agent ๐Ÿ

agent("debug this") โ€” as easy as print()

Drop agent() anywhere in your Python code to execute agentic AI workflows. Powered by Google Gemini via Agno.

PyPI Python License: MIT


โšก 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!

โš™๏ธ Configuration

from console_agent import init

init(
    api_key="...",                    # or set GEMINI_API_KEY env var
    model="gemini-2.5-flash-lite",   # default model
    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
โ”œโ”€โ”€ 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

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

console_agent-1.2.0.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

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

console_agent-1.2.0-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file console_agent-1.2.0.tar.gz.

File metadata

  • Download URL: console_agent-1.2.0.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for console_agent-1.2.0.tar.gz
Algorithm Hash digest
SHA256 f75da2af7b2013e126fd7bf9d6d3463d75b9d3e316aad8834d7ad1a1f0ddc7fe
MD5 c76d03477821864659c5e44b521d58a8
BLAKE2b-256 f1b436287c8229f7a109c7bb08b3fa5aaf7eb0eb4901c13bb45626f5c9ac4fdd

See more details on using hashes here.

File details

Details for the file console_agent-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: console_agent-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for console_agent-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5db4b075f53e121fb129f55cf8e344a65388a8da03054b6863c6928aeae09f1
MD5 5331de1cdba57cf95ff21d21dbae6f0b
BLAKE2b-256 7410d5f387d2f64018abab63db092a2361c063027641db8f97c9352d25de5a8c

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