Engineering/AI documentation

Legacy LLM Server Compatibility

Pi Model Management owns provider/model configuration while legacy LLMServer rows remain read-only migration input and Petals donors join through the governed bridge.

documented
UI Path
Settings > Pi Model Management > Legacy Compatibility
Component
SettingsView
Source Refs
7
Tests
5

Concepts: rag

Implementation Summary

Legacy LLMServer rows remain as migration input only; their classical public CRUD endpoint has been retired. Pi Model Management is the authoritative provider/model plane for both Istara and Pi Agentic Loop execution. Donated Petals capacity joins that authority only through the governed bridge and keeps its separate consent, project-scope, health, and lifecycle controls.

Frontend Surface

  • frontend/src/components/common/SettingsView.tsx
  • frontend/src/lib/modelProviders.ts
  • backend/app/core/pi_runtime/model_manager.py

State, API, And Backend Contracts

Stores

  • None recorded.

API And Backend

  • backend/app/api/routes/settings.py
  • backend/app/api/routes/petals.py

The retired LLM-server route is not mounted. Existing rows are projected

read-only for migration compatibility and are never mutated by Pi resolution.

Pi catalog/model/provider mutations remain global-admin surfaces in team mode;

public /api/settings/status is redacted and passive.

Isolated Pi Model Catalog (Pi Replacement W1)

  • backend/app/core/pi_runtime/model_manager.py (PiModelManager) is the

provider/model authority for both supported loop modes. The Pi-runtime

package never imports ComputeRegistry; the outer Petals bridge performs

consent, health, scope, and identity projection.

  • The catalog is built from four governed sources: the static

settings.pi_api_endpoints entries plus the built-in

pi-deepseek-default; explicitly healthy persisted LLMServer rows

projected read-only into the catalog as openai_compat/anthropic_compat

endpoints carrying the row's encrypted key (unhealthy rows remain

migration data and cannot consume a Pi or Research Spine slot); and local

serving at settings.ollama_host + "/v1" and

settings.lmstudio_host + "/v1" marked kind=local; plus healthy,

explicitly consented relay/browser nodes projected as kind=petals through

an authenticated loopback shim and pinned to the active project.

  • Both the legacy-row projection and the Petals projection are one-directional.

Pi never writes back to either source. Petals endpoints are selected by exact

identity, not capacity score, and same-model donor/endpoint replicas never

count as independent Research Spine coders.

  • Each catalog entry carries the capability set used for exact-identity or

capability-filtered selection: model, context_window, max_tokens,

supports_tools, supports_vision, family, cost_per_mtok,

timeout_ms, and max_retries. Selection is exact-identity or

capability-filtered only — never donor-style capacity scoring.

  • resolve(...) raises a typed PiEndpointResolutionError on any miss, and

resolve_distinct(n, ...) fails closed when fewer than n distinct

identities exist rather than silently reusing one endpoint as two.

catalog() feeds the settings model UI and benchmark comparison surfaces;

project-readable chat callers pass a project id so Petals entries are

filtered by the same admission predicate used by endpoint resolution.

When an isolated caller injects an explicit catalog, an unqualified

resolution selects its first admitted entry instead of falling back to the

built-in default endpoint, preserving the caller's authority boundary.

Live Catalog Refresh And Merged Model View

  • Model-management mutations refresh every live manager so both loop modes see

the same authoritative catalog without process restart.

PiModelManager.reset_db_projection() drops the llm_server-sourced catalog entries so the

next ensure_db_projection re-reads the database, and the module-level

reset_live_db_projections() applies that reset to every live manager

through a weakref registry — the projection stays one-directional (database

row to Pi catalog entry) and nothing Pi-side writes back to the row.

  • Pi endpoint add/update/delete and model/provider setting changes invalidate

the live catalog immediately. A stale projection is removed before the next

resolution; the retired legacy route is not required for refresh.

  • Pi endpoint POST and PUT are one authority boundary: catalog-derived fields,

endpoint URL/keychain validation, sparse-update inheritance, and credential

custody are shared, so editing a connection cannot bypass the canonical

provider/model contract or erase its secret reference.

  • Pi endpoint PUT and DELETE apply the same reserved-identity guard as POST:

pi-petals-* is owned by the consented Petals projection and

pi-deepseek-default is owned by the built-in resolver. Even a stale or

malformed persisted row cannot be mutated through user-managed CRUD.

  • backend/app/api/routes/settings.py GET /settings/models now includes a

"pi_catalog" key alongside the legacy model list in both online and

offline responses. It is an identity/capability view only — endpoint ids,

model names, and kinds — and never exposes endpoint URLs or API keys. If the

canonical Pi projection cannot be read, the route returns a typed 503

(pi_catalog_unavailable) rather than silently presenting a legacy-only

inventory.

  • The frontend does not render a legacy LLM Server section or expose its

manual provider/model form in normal Settings. PiModelManagement owns the

complete browseable + autocomplete catalog, API-key/OAuth choices, and

configured-model list. Legacy rows remain available to compatibility/migration

routes and the Pi projection; they are never silently deleted or used to

expose donated compute as a cloud catalog.

  • Chat uses the project-readable identity-only model catalog and stores an exact

endpoint_override alongside model_override, preserving provider identity

when two providers expose the same model id.

  • The shared Pi endpoint-boundary network guard applies to both worker-backed

chat and the Python-direct embeddings gateway. Ordinary tests fail closed

before public-provider HTTP when ISTARA_TEST_BLOCK_EXTERNAL_LLM=1; only

loopback, faux, Docker, and reserved test domains remain eligible for

deterministic contract coverage.

Endpoint Liveness, Thinking Level, Provider Errors And Structured Output (2026-09-25)

  • **Progress-based liveness (DEC-10).** A run is judged by progress: idle_timeout_ms bounds the

silence between streamed provider events (text, thinking and tool-call frames re-arm it; time in

Istara's own tools does not count) and max_run_ms is the total backstop. Defaults depend on

locality: remote 120 s idle / 600 s total (the OpenAI and Anthropic SDKs' 10-minute default),

local 300 s idle / 3,600 s total and 300 s for the response to start (Open WebUI's Ollama default,

llama.cpp server's read/write default). locality (auto | local | remote) infers local from

loopback, private, link-local, ULA and tailnet (100.64/10, *.ts.net) hosts, *.local,

host.docker.internal and single-label service names. The worker reports

idle_timeout_exceeded or wall_clock_budget_exceeded; the supervisor waits the idle budget plus

30 s so the worker's reason arrives first. timeout_ms (response start) may be up to 600 s. The

built-in Ollama and LM Studio entries and locally flagged servers use the local budgets.

  • **A local model that is still loading is waited for (2026-09-26).** llama.cpp and LM Studio

answer 503 "Loading model" (TGI: "Model is currently loading") while they load weights, and the

worker used to fail that turn at once. A local binding now carries load_wait_ms (the 300 s

response-start budget) and the worker retries a loading answer with backoff (1 s doubling, 10 s

steps) until the model answers or the budget is spent. The wait does not spend max_retries,

happens only before the attempt's first visible output, stops at once on abort, and a turn that

outlives it fails with the provider's message plus "the model was still loading after 300 s".

Remote endpoints never wait: a remote 503 is an outage.

  • **Thinking level.** An endpoint's thinking_level (off .. max) is the default for turns that

do not set TurnParams.thinking_mode. Before, only chat sent a level, so an always-reasoning model

(Z.ai GLM-5.3-flash) refused every other call with HTTP 400.

  • **Failure reasons.** A failed turn's TurnResult.error carries the provider's reason (for example

the provider's 400 text or wall_clock_budget_exceeded); it used to be dropped.

  • **Structured output.** The worker forces its capture tool through tool_choice. The OpenAI

Responses API is mapped (auto / required / named). Providers whose API accepts only auto (Meta)

get auto plus an instruction to call the capture tool; only a schema-valid capture call counts,

so a run without it fails closed (structured_output_missing). The provider identity comes from

the capability receipt's pi_provider, since model.provider is Istara's per-endpoint name.

  • **Pinned pi-ai 0.87.1** (2026-09-25) adds the meta provider (Muse Spark 1.1-1.3 and the

Contributor models, direct at api.meta.ai) and radius; see

docs/architecture/pi-compatibility-authority.md for the classified diff-proof.

Architecture Notes

  • Compatibility is implemented by read-only row projection, not a public legacy route. User-facing configuration is mounted through frontend/src/components/settings/PiModelManagement.tsx and documented under settings.general.
  • The frontmatter and manifest entries are the durable contract for agents updating this page after code changes.
  • When the referenced component, store, route, agent, skill, or test behavior changes, regenerate and validate the feature documentation.

Agents, Skills, LLM, MCP, And Permissions

  • RAG-related behavior depends on project context, documents, memory, or retrieval material referenced by the cited stores and routes.

Tests And Verification

  • frontend/src/lib/modelProviders.test.ts
  • tests/test_project_scope_contracts.py
  • tests/pi_production/test_w1_agentic_contract.py verifies catalog sources and prevents direct Pi-runtime registry imports.
  • tests/pi_production/test_same_model_donor_isolation.py verifies same-model plane isolation.
  • tests/petals_bridge/test_petals_bridge.py verifies consent, health, token, project pinning, dynamic refresh, and fail-closed behavior.
  • tests/test_settings_agentic_pi_endpoints.py keeps a production-style live

PiModelManager across endpoint POST/PUT/DELETE operations and verifies the

dispatcher catalog reflects each mutation immediately.

  • tests/pi_production/test_w8_embeddings_gateway.py verifies live projection-reset hooks and the merged pi_catalog view.
  • Regenerate and validate the machine manifests and static site with python scripts/feature_docs.py --seed-missing --generate-site --check.

Compass Evidence

  • Spec/task: CF-SPEC-94 / CF-1193; CF-SPEC-8 (Pi replacement W1 model catalog; W8 projection refresh and merged settings catalog)
  • Inventory source: docs/features/inventory.json

When To Update

  • Update this page whenever the listed UI components, stores, routes, model behavior, permissions, or tests change.
  • Regenerate the site and machine manifests with python scripts/feature_docs.py --seed-missing --generate-site --check.