Skip to content

Inference Path End-to-End Validation

This document describes the inference path architecture and validation approach for Liminal.

Architecture Overview

The inference path connects the desktop application to the Vireon managed inference proxy:

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐     ┌─────────────────────────┐
│   Desktop App   │ ──▶ │    Sidecar      │ ──▶ │    Harness      │ ──▶ │ api.vireondynamics.com  │
│    (Flutter)    │     │   (liminald)    │     │  (AgentHarness) │     │   (Managed Inference)   │
└─────────────────┘     └─────────────────┘     └─────────────────┘     └─────────────────────────┘
        │                       │                       │                         │
        │   WebSocket           │   HTTP/REST          │   OpenAI SDK           │
        │   (127.0.0.1)         │   (in-process)       │   (Bearer JWT)         │
        │                       │                       │                         │
        └───────────────────────┴───────────────────────┴─────────────────────────┘

Key Components

1. Desktop App (apps/liminal_desktop)

  • Native Flutter UI
  • Spawns liminald sidecar via packages/sidecar/src/index.ts
  • Communicates over WebSocket using @liminal/protocol
  • Reads handshake from ~/.liminal/sidecar.json

2. Sidecar (packages/sidecar)

  • liminald - Node.js sidecar process
  • WsServer - Token-gated WebSocket server on ephemeral port
  • ChatRegistry - Manages chat sessions and harness instances
  • ChatOrchestrator - Delegates to parallel workers

3. Harness (packages/core)

  • AgentHarness - ReAct loop engine
  • resolveProviderConfigWithInference() - Routes to managed or BYOK
  • inference_provider.ts - Managed inference credential resolution
  • inference_session.ts - Session JWT caching (15min TTL)

4. Managed Inference Proxy (api.vireondynamics.com)

  • OpenAI-compatible API at /v1/inference
  • Session management at /api/inference/session
  • Model catalog at /api/inference/models
  • Usage status at /api/inference/status

Environment Variables

VariableDefaultPurpose
AGENT_INFERENCE_MODEautobyok | managed | auto
AGENT_INFERENCE_BASE_URLhttps://api.vireondynamics.com/v1/inferenceManaged proxy root
AGENT_INFERENCE_SESSION_URLhttps://www.vireondynamics.com/api/inference/sessionSession JWT endpoint
AGENT_INFERENCE_SESSION_TOKENPinned session JWT for CI
AGENT_INFERENCE_PREFER_MANAGED1In auto mode, prefer managed
AGENT_MANAGED_PROVIDERautoauto | bedrock | openrouter | kimchi

Validation Script

Run the end-to-end validation:

bash
npx tsx scripts/validate-inference-path.ts

Validation Steps

  1. Core Configuration

    • Managed inference base URL verification
    • Inference mode resolution
    • Managed provider preference
  2. Provider Resolution

    • BYOK provider sync resolution
    • Provider resolution with inference
    • Managed OpenRouter credentials
  3. Managed Inference Status

    • Inference usage status (credits/entitlement)
    • Managed inference model catalog
  4. Live API Call

    • Chat completion through managed inference proxy

Example Output

Liminal Inference Path Validation

This script validates the end-to-end inference path:
  desktop -> sidecar -> harness -> api.vireondynamics.com

=== Core Configuration ===
✓ Base URL matches: https://api.vireondynamics.com/v1/inference
✓ Mode: auto
✓ Provider preference: auto

=== Provider Resolution ===
✓ BYOK provider: AGENT_API_KEY @ https://openrouter.ai/api/v1
✓ Provider: VIREON_MANAGED @ https://api.vireondynamics.com/v1/inference
✓ Credentials resolved: route=managed, base=/v1/inference

=== Managed Inference Status ===
✓ Credits: $15.00 remaining
✓ Catalog: 42 models from bedrock (us-east-1)

=== Live API Call ===
✓ Completion OK (847ms): "pong"

Summary: 9/9 passed

Gap Detection

The validation script identifies common gaps:

  • No BYOK fallback: Set AGENT_API_KEY in .env
  • No Pro license: Run liminal login for managed inference
  • Credits exhausted: Top up at Account → Managed inference
  • Auth errors: Check license/session token validity

Unit Tests

Run the unit tests:

bash
npx tsx --test scripts/validate-inference-path.test.ts

Tests cover:

  • managedInferenceBaseUrl() returns correct URL
  • resolveInferenceMode() respects env overrides
  • resolveProviderConfig() throws without API key
  • isInferenceBudgetExceededError() classifies 402 errors
  • isManagedInferenceAuthError() classifies 401 auth errors

Troubleshooting

SymptomCauseFix
"Sign in to Vireon first"No license resolvedRun liminal login
AGENT_INFERENCE_MODE=managed requires pro.managed_inferenceNot Pro+Use byok mode
HTTP 402 / "credit limit reached"Credits exhaustedTop up at Account page
"Managed providers temporarily busy"Upstream rate limitRetry shortly
Empty catalogNo license or network errorCheck login and connectivity
  • packages/core/src/inference_provider.ts - Managed inference client
  • packages/core/src/inference_session.ts - Session JWT cache
  • packages/core/src/provider_config.ts - Provider routing
  • packages/sidecar/src/index.ts - Sidecar entry point
  • docs/guides/managed-inference.md - User-facing docs

Liminal AI · Beta docs (v0.1.2) · Marketing: vireondynamics.com/liminal · Compare: vireondynamics.com/liminal/compare