Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

docs(inference): update README to reflect current module structure and dependencies

Steven Enamakelb03e8866cdf8
diff --git a/crates/openhuman-core/src/inference/README.md b/crates/openhuman-core/src/inference/README.md
index ad8beab195..e5ae85804b 100644
--- a/crates/openhuman-core/src/inference/README.md
+++ b/crates/openhuman-core/src/inference/README.md
@@ -5,7 +5,7 @@ Unified inference domain: the canonical home for everything LLM/STT/TTS/embeddin
## Responsibilities
- Resolve workload names (`chat`, `reasoning`, `agentic`, `coding`, `memory`, `embeddings`, `heartbeat`, `learning`, etc.) and provider strings (`openhuman`, `cloud`, `ollama:<model>`, `lmstudio:<model>`, `claude_agent_sdk:<model>`, `claude-code:<model>`, `<slug>:<model>[@<temp>]`) to a concrete `Arc<dyn tinyinference::ChatModel<()>>` + model id.
-- Manage the local AI runtime: detect/spawn/adopt `ollama serve` and LM Studio, install/run Piper (TTS), track download progress, and enforce a minimum-context-window floor. Local STT (whisper.cpp) was retired; STT is now cloud/engine-configurable via `voice_server.stt_engine` (see `config/migrations/retire_local_whisper_stt.rs`).
+- Manage the local AI runtime: detect/spawn/adopt `ollama serve`, probe LM Studio over HTTP (never spawned), install/run Piper (TTS), track download progress, and enforce a minimum-context-window floor. Local STT (whisper.cpp) was retired; STT is now cloud/engine-configurable via `voice_server.stt_engine` (see `config/migrations/retire_local_whisper_stt.rs`).
- Provide chat, vision (multimodal), summarization, embeddings, sentiment, and "should react" inference operations.
- Preserve config-rejection, billing, authentication, and retry classification while TinyAgents owns model-call retry execution.
- Resolve abstract tier names (`reasoning-v1`, `agentic-v1`, `coding-v1`, etc.) through the TinyAgents `ModelRouter` in `crates/openhuman-core/src/agent/tinyagents/routes.rs` and the provider factory here.
@@ -13,8 +13,8 @@ Unified inference domain: the canonical home for everything LLM/STT/TTS/embeddin
- Expose an OpenAI-compatible `/v1/*` HTTP endpoint guarded by a stable user-managed external bearer.
- Detect device hardware profile and recommend/apply local model presets/tiers.
- Maintain the built-in BYOK provider preset catalog used by Connections → API keys → LLM.
- The current matrix is `config/schema/cloud_providers.rs`; credentials are
- stored under `provider:<slug>` in the auth-profile store.
+ The current matrix is `tinymemory_api::host::cloud_providers`, re-exported through
+ `config/schema/cloud_providers.rs`; credentials are stored under `provider:<slug>` in the auth-profile store.
## Key files
@@ -22,7 +22,10 @@ Unified inference domain: the canonical home for everything LLM/STT/TTS/embeddin
| --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mod.rs` | Domain root; module decls + re-exports; wires `inference.*` controller schemas/controllers. |
| `ops.rs` | Canonical handler file — `inference_*` business logic returning `RpcOutcome<T>`; delegates to `local`, `provider`, `sentiment`, `device`, `presets`, `openai_oauth`. Includes Sentry-noise suppression for expected provider/user-config failures. |
-| `schemas.rs` | `inference.*` controller schemas + `handle_*` fns + param DTOs. |
+| `schemas.rs` + `schemas_part_0{1,2}.rs` | `inference.*` controller schemas + `handle_*` fns + param DTOs. |
+| `auth_error_registry.rs` | Process-lived registry of rejected BYO keys (401/403): `record`/`clear`/`snapshot` feed `inference.provider_auth_errors` and the one-shot `DomainEvent::ProviderApiKeyRejected`. |
+| `vision_models.rs` | `is_vision_capable` — which local model ids accept image input; every vision path resolves through it first. |
+| `temperature.rs` | `temperature_for_model` — omits `temperature` for models listed in `config.temperature_unsupported_models` (shell-style `*` globs). |
| `types.rs` | Serde DTOs: `LocalAiStatus`, `LocalAiAssetsStatus`, `LocalAiDownloadsProgress`, `LocalAiEmbeddingResult`, `LocalAiSpeechResult`, `LocalAiTtsResult`, etc. |
| `device.rs` | `DeviceProfile` hardware detection (RAM/CPU/GPU/OS), cached. |
| `model_ids.rs` | Effective chat/vision/embedding/STT/TTS/quantization model id resolution from config. |
@@ -32,9 +35,9 @@ Unified inference domain: the canonical home for everything LLM/STT/TTS/embeddin
| `parse.rs` / `paths.rs` | Output parsing helpers / on-disk model artifact paths. |
| `local/` | Local runtime manager (was `local_ai/`). See `local/README.md`. |
| `local/core.rs` | `LocalAiService` singleton (`global`/`try_global`), `model_artifact_path`. |
-| `local/ops.rs` | Local RPC entrypoints (`local_ai_status/prompt/summarize/vision_prompt/embed/should_react`, `ReactionDecision`); re-exported as `local::rpc`. |
+| `local/ops.rs` + `local/ops_part_0{1,2}.rs` | Local RPC entrypoints (`local_ai_status/prompt/summarize/vision_prompt/embed/should_react`, `ReactionDecision`); re-exported as `local::rpc`. |
| `local/schemas.rs` | Local-runtime `inference.*` controller schemas + handlers. |
-| `local/ollama.rs`, `local/lm_studio.rs` | Provider-specific runtime drivers; base-url resolution. |
+| `local/ollama.rs`, `local/lm_studio.rs` | Ollama / LM Studio HTTP wire types and base-url resolution (`ollama_base_url[_from_config]`, `validate_ollama_url`, `lm_studio_base_url`). |
| `local/install*.rs`, `local/voice_install_common.rs` | Ollama/Piper install + shared download logic. No Whisper install any more. |
| `local/model_requirements.rs` | `MIN_CONTEXT_TOKENS`, `evaluate_context`, `ContextEligibility`. |
| `local/profile.rs` | `LocalProviderProfile` capability metadata (tool-dispatch strategy, context defaults, request-body quirks) per local provider type. |
@@ -47,14 +50,13 @@ Unified inference domain: the canonical home for everything LLM/STT/TTS/embeddin
| `provider/factory.rs` + `factory_part_0{1..4}.rs` | `create_chat_model*`, `provider_for_role`, provider-string grammar, access gates, and local/cloud/CLI model construction; `BYOK_INCOMPLETE_SENTINEL`. |
| `provider/crate_openai.rs`, `provider/crate_anthropic.rs` | TinyAgents OpenAI-compatible and Anthropic Messages API model builders (managed, BYOK, and local endpoints; prompt caching). |
| `provider/openhuman_backend_model.rs` | Managed OpenHuman backend `ChatModel` with session JWT, billing metadata, and thread context. |
-| `provider/openai_codex.rs` | Codex OAuth/Responses transport as a host `ChatModel`. |
+| `provider/openai_codex.rs` | `pub(crate)` Codex routing metadata (`OpenAiCodexRouting`, `resolve_openai_codex_routing`): re-targets the `openai` slug at the ChatGPT Codex backend with account/originator headers when Codex OAuth tokens exist. Not a `ChatModel` itself. |
| `provider/claude_agent_sdk/` | Claude Agent SDK subprocess provider (`protocol.rs`, `subprocess.rs`). |
| `provider/claude_code/` | Claude Code CLI provider (`claude-code:<model>`). Drives the `claude` CLI over stream-json; see `provider/claude_code/README.md`. |
| `provider/config_rejection.rs`, `provider/billing_error.rs`, `provider/error_classify.rs`, `provider/error_code.rs`, `provider/fallback_diagnostics.rs`, `provider/chat_template.rs` | Error classifiers (unknown-model / config rejection / budget exhausted / chat-template rejection / backend error codes / background-workload fallback diagnostics). |
-| `provider/auth.rs` | Provider auth-profile resolution shared across factory paths. |
-| `temperature.rs`, `agent/tinyagents/thread_context.rs` | Per-workload temperature policy and ambient thread-context plumbing (`crates/openhuman-core/src/agent/tinyagents/`). |
+| `provider/auth.rs` | `AuthStyle` (`None`/`Bearer`/`XApiKey`/`Anthropic`/`Custom`) — wire auth style shared by the crate-native builders. |
| `provider/ops/` | Split from a single `ops.rs`: `sanitize` (secret scrubbing), `http_error` (HTTP error classification, Sentry routing, `api_error`), `models` (`list_configured_models`), `provider_factory` (`ProviderRuntimeOptions`, `list_providers`). |
-| `provider/schemas.rs` | Provider-layer schemas. |
+| `provider/schemas.rs` | Defines a `providers.list_models` controller that is **not** wired into `core/all.rs`; the live method is `inference.list_models` (`openhuman.providers_list_models` survives only as a legacy alias). |
| `voice/` | Inference implementations imported by `crate::voice`. |
| `voice/cloud_transcribe.rs`, `voice/local_speech.rs` | Hosted STT and local Piper TTS. |
| `voice/streaming.rs`, `voice/postprocess.rs` | Streaming transcription and post-processing. |
@@ -89,7 +91,8 @@ Also exposes a non-RPC HTTP router (`http::router()`) nested at `/v1` by `crates
## Events
-- Publishes `DomainEvent::SessionExpired` from `provider/ops.rs` when a provider chat attempt fails auth, so the credentials layer can clear/refresh the session.
+- Publishes `DomainEvent::SessionExpired` from `provider/ops/http_error_part_02.rs` (`publish_backend_session_expired`) and `provider/openhuman_backend_model.rs` when the managed backend rejects a session, so the credentials layer can clear/refresh it.
+- Publishes `DomainEvent::ProviderApiKeyRejected` once per provider from `provider/ops/http_error_part_02.rs` the first time a BYO key is rejected (401/403), gated by `auth_error_registry::record`.
- No `bus.rs` / `EventHandler` subscribers in this domain.
## Persistence
@@ -110,7 +113,8 @@ Also exposes a non-RPC HTTP router (`http::router()`) nested at `/v1` by `crates
- `crate::util` — small shared helpers.
- `crate::core::all` — `ControllerFuture`, `RegisteredController` (controller registry).
- `crate::core::types` — `ControllerSchema`, `FieldSchema`, `TypeSchema`.
-- `crate::core::bus` (`BUS.publish`) / `crate::core::events::DomainEvent` — `SessionExpired` publishing on auth failure.
+- `crate::core::bus` (`BUS.publish`) / `crate::core::events::DomainEvent` — `SessionExpired` / `ProviderApiKeyRejected` publishing on auth failure.
+- `crate::security::live_policy` + `crate::security::egress` — Privacy-Mode `LocalOnly` enforcement and egress descriptors at the chat-factory chokepoint (`enforce_local_only_inference`, `emit_inference_egress` in `provider/factory_part_01.rs`).
- `crate::core::observability` — `expected_error_kind` for Sentry-noise classification.
- `crate::core::jsonrpc` — endpoint mounting reference for `/v1`.
- `crate::core::auth` — bearer auth for the OpenAI-compatible endpoint.
@@ -118,7 +122,7 @@ Also exposes a non-RPC HTTP router (`http::router()`) nested at `/v1` by `crates
## Used by
-Widely depended on by the agent layer (`agent/harness`, `agent/harness/session`, `agent/tools`, `agent/triage`, `agent/harness/subagent_runner`, `agent/learning`, `agent/context`), `voice`, `memory/tree/tree_runtime`, `channels`, `web_chat`, `inference/embeddings`, `threads`, and `migrations`/`config/schema`.
+Widely depended on by the agent layer (`agent/harness`, `agent/harness/session`, `agent/tools`, `agent/triage`, `agent/harness/subagent_runner`, `agent/learning`, `agent/context`, `agent/tinyagents`), `voice`, `memory/tree/tree_runtime`, `channels`, `web_chat`, `flows/tinyflows/caps`, `cron/scheduler`, `inference/embeddings` (Ollama base-url resolution from `local`), `threads`, `security/credentials` (`local::global`), `core/runtime/builder` (`local::try_global` on shutdown), and `config/migrations`/`config/schema`. `grep -rn 'inference::provider::\|inference::local::' crates/openhuman-core/src` is the authoritative list.
## Notes / gotchas