Skip to main content

Efficient Agent Router — routes tasks to the best LLM under quality, latency, cost, and safety constraints

Project description

Efficient Agent Router (EAR)

Efficient Agent Router (EAR) is a Python-first orchestration service that selects and executes the best LLM for a request based on quality, cost, latency, context window, and safety constraints.

Goals

  • Route each request to the most suitable model for the task.
  • Reduce token burn through cost-aware model ranking.
  • Protect sensitive input with prompt-injection and PII safeguards.
  • Provide a clean CLI first, then expose the same logic through MCP.

Current Delivery Strategy

  1. Build and validate core routing engine through CLI.
  2. Harden reliability, guardrails, and observability.
  3. Expose stable capabilities through MCP server.

Tech Stack

  • Python 3.12+
  • asyncio
  • Typer CLI
  • Pydantic v2
  • httpx for OpenRouter model metadata
  • pytest, pytest-asyncio, pytest-cov
  • bandit and pip-audit for security controls

Planned Repository Layout

  • docs/
    • system_prompt.md
    • execution_plan.md
    • adr/
  • src/
    • ear/
      • router_engine.py
      • registry.py
      • guardrails.py
      • fallback.py
      • metrics.py
      • cli.py
      • mcp_server.py
  • tests/
    • test_registry.py
    • test_router_engine.py
    • test_guardrails.py
    • test_fallback.py
    • test_cli.py
    • test_mcp_server.py

Core Workflow

  1. Accept user task input and options (task hint, budget priority, context profile).
  2. Run safety prechecks (injection and PII policy).
  3. Load model metadata from OpenRouter registry cache.
  4. Compute suitability score and candidate ranking.
  5. Execute via selected model and apply cascade fallback if needed.
  6. Return result with routing rationale and metric snapshot.

Routing Model

The router evaluates candidate models using a weighted suitability function:

S = Quality / (Cost * Latency)

Where score inputs are normalized and constrained by policy:

  • Context window threshold
  • Budget priority
  • Safety allowlist and PII policy
  • Task-specific boosts (coding, planning, research)

CLI Design (Phase 1)

Expected commands:

  • ear route "" --task coding --budget medium
  • ear inspect-models
  • ear stats --session

Expected output modes:

  • Human-readable summary
  • JSON output for scripting pipelines

MCP Design (Phase 2)

  • Tool: route_and_execute
  • Resources: model performance metrics, cost per session
  • Transport: stdio first, optional SSE extension

Configuration

Environment variables (minimum):

  • OPENROUTER_API_KEY
  • EAR_REGISTRY_TTL_SECONDS
  • EAR_DEFAULT_BUDGET
  • EAR_MAX_RETRIES

Recommended local setup steps:

  1. Create and activate virtual environment.
  2. Install dependencies.
  3. Populate .env with OPENROUTER_API_KEY.
  4. Run tests and quality checks before first run.

Quality and Security Requirements

  • 100% statement and branch coverage for routing core.
  • Deterministic tests with mocked external dependencies.
  • Security linting with bandit.
  • Dependency auditing with pip-audit.
  • No plaintext secret logging.

Milestones

  • M1: Registry and schema baseline
  • M2: Router core and CLI
  • M3: Guardrails and metrics
  • M4: MCP server and CI/CD gates

Contributing Expectations

  • Preserve clean architecture boundaries.
  • Add tests for every logic branch touched.
  • Update ADRs when making architecture-affecting decisions.
  • Keep operational docs current with behavior changes.

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

efficient_agent_router_ear-0.10.0.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

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

efficient_agent_router_ear-0.10.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file efficient_agent_router_ear-0.10.0.tar.gz.

File metadata

File hashes

Hashes for efficient_agent_router_ear-0.10.0.tar.gz
Algorithm Hash digest
SHA256 7cc8ec29231394a64f276443c7f24477eceb7b40a05c59f20fac6049d9475b8a
MD5 4a4264d9cdf90f546d77455b2a72ff6b
BLAKE2b-256 5dc17a078a51d51943d64c654df3853ef0cd4572d556917f3bb592da5262da1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for efficient_agent_router_ear-0.10.0.tar.gz:

Publisher: publish-pypi.yml on ShanKonduru/efficient-agent-router-ear

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file efficient_agent_router_ear-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for efficient_agent_router_ear-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18e2051f34df60c2842a7d62200bd6f80f0e555c24b231429cff378e2c97db4e
MD5 3c91b1610bdaab689c5556a2ceddab84
BLAKE2b-256 1e2b025ed77875587bb6ceded01954a3859d2f0f48c5c13392bd751a2da1bbbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for efficient_agent_router_ear-0.10.0-py3-none-any.whl:

Publisher: publish-pypi.yml on ShanKonduru/efficient-agent-router-ear

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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