Skip to main content

Anviksha Runtime Engine: adaptive AI execution runtime

Project description

Anviksha Runtime Engine (ARE)

Anviksha Runtime Engine is an adaptive AI execution runtime. Applications describe intent; the runtime plans, selects capabilities, executes the plan, records state, applies policies, and returns a structured response — all without developers manually orchestrating models, tools, or workflows.

Philosophy: Define the destination. The runtime decides the journey.


Quick Start

from anviksha import Runtime, RuntimeConfig

# Offline mode — no LLM required
runtime = Runtime(config=RuntimeConfig(register_llm=False))

# Math → calculator (deterministic)
response = runtime.execute("2 + 3 * 4")
print(response.output)        # 14.0

# Search → retrieval (BM25)
response = runtime.execute("search for python runtime")
print(response.output)        # ranked results

# Python evaluation (safe AST)
response = runtime.execute("evaluate sum(range(100))")
print(response.output)        # 4950

# Async
import asyncio
response = asyncio.run(runtime.aexecute("2 ** 10"))
print(response.output)        # 1024

# Inspect execution
print(response.status)        # succeeded
print(response.diagnostics)   # planner decisions
print(response.metadata)      # timeline, events, cost

Architecture

Application
    │
    ▼
┌─────────────────────────────────────┐
│         Runtime (SDK)               │
│  execute / aexecute / astream       │
└─────────────────────────────────────┘
    │
    ▼
┌─────────────────────────────────────┐
│         Planner                     │
│  classifies intent, selects caps    │
└─────────────────────────────────────┘
    │
    ▼
┌─────────────────────────────────────┐
│      Policy Engine                  │
│  validates plan & response          │
└─────────────────────────────────────┘
    │
    ▼
┌─────────────────────────────────────┐
│      Execution Engine               │
│  parallel step execution + retry    │
└─────────────────────────────────────┘
    │                           │
    ▼                           ▼
┌──────────┐           ┌──────────────┐
│ Capability│◄─────────│ State Manager│
│ Registry  │  events  │ + SQLite     │
└──────────┘           └──────────────┘

10 RFCs implemented: Runtime Architecture, Execution Lifecycle, Planner, Capability Registry, Execution Engine, Policy Engine, State Manager, Observability, Plugin SDK, Public Python SDK.


Features

Feature Status
Intent classification (9 types)
Safe AST-based calculator
Text retrieval (BM25)
Session memory (key-value)
Safe Python evaluation
HTTP fetch capability
Sandboxed filesystem
HTTP LLM capability (OpenAI-compatible)
Parallel step execution
Retry with exponential backoff
Plan validation (dependencies, capability existence)
Minimum confidence policy
Immutable state timeline
SQLite persistent state
Structured observability events
OpenTelemetry export (optional)
Plugin auto-discovery (entry points)
No silent fallbacks — every error is actionable

Configuration

Variable Default Description
ANVIKSHA_LLM_API_BASE OpenAI-compatible API base URL
ANVIKSHA_LLM_API_KEY API key
ANVIKSHA_LLM_MODEL Model name
ANVIKSHA_MAX_RETRIES 3 Max capability retry attempts
ANVIKSHA_RETRY_BASE_DELAY_S 1.0 Initial retry backoff
ANVIKSHA_RETRY_MAX_DELAY_S 30.0 Maximum retry delay
ANVIKSHA_STATE_DB_PATH SQLite path for persistence
OTEL_EXPORTER_OTLP_ENDPOINT OpenTelemetry endpoint

Performance

Benchmark                     Ops/sec
─────────────────────────────────────
Calculator throughput          4,727/s
Python evaluation             26,068/s
Memory operations            749,597/s
Retrieval (1000 docs)            155/s
p50 latency                     0.13ms

Testing

96 tests (49 original + 47 new Phase 2) — unit, integration, concurrency, property-based.

pip install -e ".[dev]"
pytest tests/ -v --cov

Project Structure

src/anviksha/
├── __init__.py
├── config.py                  # Env-based RuntimeSettings
├── exceptions.py              # Exception hierarchy
├── types.py                   # Immutable data models
├── capabilities/
│   ├── base.py                # Capability protocol & metadata
│   ├── registry.py            # Filtering/sorting registry
│   ├── builtins.py            # AST calculator
│   ├── llm.py                 # HTTP LLM capability
│   ├── retrieval.py           # BM25 text retrieval
│   ├── memory.py              # In-memory key-value store
│   ├── python_exec.py         # Safe Python evaluation
│   ├── http_client.py         # HTTP fetch capability
│   └── filesystem.py          # Sandboxed file I/O
├── execution/engine.py        # Parallel execution + retry
├── observability/events.py    # Structured event sink
├── planner/default.py         # Rule-based intent classifier
├── plugins/sdk.py             # Plugin protocol & metadata
├── plugins/discovery.py       # Entry-point auto-discovery
├── policy/engine.py           # Policy engine + min confidence
├── sdk/runtime.py             # Public Runtime API
└── state/manager.py           # Immutable state timeline
    state/persistence.py       # SQLite persistent state

License

MIT

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

anviksha-0.2.0.tar.gz (59.0 kB view details)

Uploaded Source

Built Distribution

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

anviksha-0.2.0-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file anviksha-0.2.0.tar.gz.

File metadata

  • Download URL: anviksha-0.2.0.tar.gz
  • Upload date:
  • Size: 59.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/44.0 requests/2.32.4 requests-toolbelt/1.0.0 urllib3/2.2.1 tqdm/4.67.1 importlib-metadata/8.6.1 keyring/25.6.0 rfc3986/1.5.0 colorama/0.4.6 CPython/3.12.4

File hashes

Hashes for anviksha-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cf2b3f4ffb97766529ea81cec8fe644e5ccc70d3919fee75c80fb5db68ea84b3
MD5 224821cf741f75b99093cb5167fb704c
BLAKE2b-256 79d6e319b0697c035bb3bf8cf66203748a64cedf1eca49e4c711adaf4ee2eff3

See more details on using hashes here.

File details

Details for the file anviksha-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: anviksha-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 29.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/44.0 requests/2.32.4 requests-toolbelt/1.0.0 urllib3/2.2.1 tqdm/4.67.1 importlib-metadata/8.6.1 keyring/25.6.0 rfc3986/1.5.0 colorama/0.4.6 CPython/3.12.4

File hashes

Hashes for anviksha-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92b6c6c7ff6dec939785ee6eaa2fd19309d19aec1b9c3dd522edacb15e364788
MD5 72aee8169cafcdd2bed4563f5ee705bc
BLAKE2b-256 7b549a7f02c93d1c9b264e21b3f5fefb1d0b9800cb36703025a9c6770f62b71a

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