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-1.0.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-1.0.0-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: anviksha-1.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c4595a16723bb4f9c531aa51dcb20251e76273952c311fa1b13dd84d47639feb
MD5 8a68e7461984eed750113140a0233928
BLAKE2b-256 536ba2c0316fe87a78569b02fb4309ffb0b5d15b7ca7192672573ad131b40f91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: anviksha-1.0.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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a40ffb767b62e9c136f472042b0b5a6cfdeb34d2a23de0e947c81fd37b4882a
MD5 c8f019b5b4861189aa6c90ab2df3e117
BLAKE2b-256 bcc26876ab6a73d09b8ba89fba4ee21ddff106879009403eeb8926480ced37a5

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