Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,6 @@ tauri-plugin-global-shortcut = { git = "https://github.com/tauri-apps/plugins-wo
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", rev = "c6561ab6b4f9e7f650d4fc8c53fd8acc9b65b9b2" }
tauri-plugin-notification = { path = "vendor/tauri-plugin-notification" }

# Match the root Cargo world: TinyCortex's temporary git pin must resolve to
# the vendored TinyAgents crate to preserve one embedding trait identity.
[patch."https://github.com/senamakel/tinyagents"]
tinyagents = { path = "../../vendor/tinyagents" }

[dev-dependencies]
# `test-util` enables `#[tokio::test(start_paused = true)]` for the
# idle-watchdog unit tests in `cdp/session.rs` (#1213).
Expand Down
25 changes: 18 additions & 7 deletions docs/tinyagents-drift-ledger.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TinyAgents Drift Ledger (Phase 0)
# TinyAgents Drift Ledger

**Purpose.** The TinyAgents migration spans `inference`, `tools`, and
`agent_orchestration`, while the OpenHuman host will keep evolving. This ledger
Expand All @@ -22,12 +22,12 @@ be upstreamed, retained, or deleted before each phase cuts over.
| Thing | Value |
| --- | --- |
| Host repo | `tinyhumansai/openhuman` |
| Host branch | `docs/tinyagents-port-plan` |
| Host audit base | `42ce5c0e9` (`origin/main`, 2026-07-04) |
| Plan commit | `24f200e49` (`docs: TinyAgents port plan`) |
| Host branch | `feat/tinyagents-migration-2026-07-22` |
| Host audit base | `5b8a9f269` (`upstream/main`, 2026-07-22) |
| Active plan | `docs/tinyagents-migration-plan-2026-07-22.md` |
| TinyAgents submodule | `vendor/tinyagents` -> `tinyhumansai/tinyagents` |
| Phase 0 target | `v1.6.0` / `e72036d847b589044aa9a4add1b34544b92a293d` |
| Current host pin | `v1.8.0-1-g7c6e81a` ([tinyagents#49](https://github.com/tinyhumansai/tinyagents/pull/49) **merged** onto v1.8.0 main) |
| Current host pin | `v2.1.0` / `2583fcc` (vendored tag; root requirement `2.1`) |
| Verification PR | [openhuman#4769](https://github.com/tinyhumansai/openhuman/pull/4769) — Motion A + Motion B checkpoint. **CI fully green** (`PR CI Gate` + `Rust Core Coverage` + fmt/clippy); 14,437 Rust tests pass. First full CI verification of this branch. |

## Baseline Snapshot
Expand Down Expand Up @@ -69,6 +69,16 @@ work started. Counts include Rust files only.

## Motion B — Provider-Build Cutover (crate-native `ChatModel` construction)

The closure rows below supersede older deferred/pending prose retained later in
this section as investigation history.

| # | Area | Status | Evidence / action |
| --- | --- | --- | --- |
| P1-10 | Wire-equivalent BYOK cloud slugs | **CLOSED** | [openhuman#4780](https://github.com/tinyhumansai/openhuman/pull/4780) routed eligible slugs to crate-native `OpenAiModel`. |
| P1-11 | OpenAI/Codex/custom cloud slugs | **CLOSED** | [openhuman#4782](https://github.com/tinyhumansai/openhuman/pull/4782) completed the configured cloud-slug client cutover, including Responses API construction. |
| P1-12 | Host workload routing | **CLOSED** | [openhuman#4783](https://github.com/tinyhumansai/openhuman/pull/4783) adopted crate `ModelRouter` for fallback and capability decisions. |
| P1-13 | Crate-native registered turn models / `compatible*.rs` deletion | **CLOSED** | [openhuman#4784](https://github.com/tinyhumansai/openhuman/pull/4784) moved the hot turn path and deleted the former `compatible*.rs` cluster. The collapsed `legacy_provider.rs` facade and the broader legacy `Provider` stack remain WP-1 deletion work; see the deletion ledger. |

Motion A confined all `Provider` handling to the seam + factory. Motion B
replaces the *construction* of host `Provider`s with crate-native
`ChatModel`s at each build boundary, so `compatible*.rs` can eventually be
Expand Down Expand Up @@ -166,7 +176,8 @@ of P1-9). Two sub-motions:
| Step | Status | Evidence |
| --- | --- | --- |
| Crate high-level router | **DONE** | [tinyagents#54](https://github.com/tinyhumansai/tinyagents/pull/54) `registry::router::{ModelRouter, WorkloadRoute}` (merged `4fc8cd8`) — declarative workload-tier table (alias→model, `CapabilitySet` gate, same-family fallbacks) filling the long-declared `ComponentKind::Router`; holds no models, no I/O. |
| Host adopts `ModelRouter` for fallback + capability | **IN PROGRESS** | `tinyagents/routes.rs`: `OH_WORKLOAD_ROUTER` (`LazyLock<ModelRouter>`) now backs `route_fallback_policy` + `turn_required_capabilities`; deleted the hand-rolled `same_family_fallbacks`. Behavior-neutral (parity tests pin the exact chains + vision gate incl. `hint:vision`). `build_route_models`' per-tier `ProviderModel` construction (the P3-B client swap) is untouched. Host pin bumped `8e57665` → `4fc8cd8` (adds #53 langfuse run-tree + #54 router). |
| Host adopts `ModelRouter` for fallback + capability | **CLOSED** | [openhuman#4783](https://github.com/tinyhumansai/openhuman/pull/4783) made `tinyagents/routes.rs::OH_WORKLOAD_ROUTER` authoritative for fallback and required capabilities. |
| Registered tier models become crate-native | **CLOSED** | [openhuman#4784](https://github.com/tinyhumansai/openhuman/pull/4784) completed the P3-B hot-path client swap and deleted the former `compatible*.rs` cluster. Residual `ProviderModel` and the collapsed legacy facade are tracked separately in WP-1. |

## Host Validation Notes

Expand All @@ -190,7 +201,7 @@ error emitted before the cap.
| Phase 0 - version alignment | P0-1, P0-2, P0-3, P0-4, P0-5, P0-6 | **CLOSED** |
| Phase 1 - quick upstream ports | SchemaCleanr, error classification, model context, reasoning channel, worktree isolation, display metadata, time tools | **PARTIAL HOST CUTOVER** |
| Phase 2 - tool model and builtin families | ToolResult structure, permission model, ToolAccess, edit tracking, filesystem/network/time tools | **NOT STARTED** |
| Phase 3 - provider consolidation | OpenAI-compatible provider cutover, retry ownership, backend envelope split | **NOT STARTED** |
| Phase 3 - provider consolidation | OpenAI-compatible client cutover and crate router adoption | **CLIENT CUTOVER CLOSED; LEGACY STACK REMOVAL IN WP-1** |
| Phase 4 - orchestration consolidation | TaskStore/SteeringRegistry lifecycle, status vocabulary, session durability | **NOT STARTED** |
| Phase 5 - workflow/team generic slices | Validation/scheduling slice evaluation | **NOT STARTED** |
| Phase 6 - cleanup and docs | Transitional shim deletion and architecture docs | **NOT STARTED** |
Expand Down
29 changes: 29 additions & 0 deletions docs/tinyagents-full-migration-plan/99-deletion-ledger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# TinyAgents migration deletion ledger

This ledger records host-side removals required by
[`tinyagents-migration-plan-2026-07-22.md`](../tinyagents-migration-plan-2026-07-22.md).
A row moves to `DELETED` only after its crate-backed replacement and the named
parity evidence are in place. Generic code moved into `vendor/tinyagents` must
also name its upstream PR before the host copy is removed.

| Work package | Host artifact | Preconditions / replacement | Status | Evidence |
| --- | --- | --- | --- | --- |
| WP-1 | `inference/provider/router.rs` + tests | Crate `ModelRouter` owns live routing | PENDING | #4783 adopted the router; legacy provider consumers remain |
| WP-1 | `inference/provider/reliable.rs` + tests | Crate retry/fallback owns every model call | PENDING | Retargeted provider wire-parity tests |
| WP-1 | `inference/provider/legacy_provider.rs` and `compatible` alias | Every OpenAI-compatible slug uses crate `OpenAiModel` | PENDING | #4780/#4782/#4784 client cutover; residual legacy callers must be removed |
| WP-1 | `inference/provider/traits.rs` + tests | No `impl Provider`; consumers use crate model/message/usage types | PENDING | Consumer sweep + `inference_provider_e2e` and `agent_harness_e2e` |
| WP-1 | `tinyagents/model.rs::ProviderModel` / `MaxTokensModel` | Tier and bespoke models are direct `ChatModel`s | PENDING | `rg ProviderModel src` empty |
| WP-1 | `tinyagents/convert.rs` message conversion | No host `ChatMessage`; retain tool-schema conversion until WP-4 | PENDING | Conversion tests moved or retired |
| WP-1 | `inference/provider/crate_provider.rs` | No legacy `Provider` consumer needs the reverse adapter | PENDING | `rg 'impl Provider' src` empty |
| WP-2 | `routing/{policy,quality,factory}.rs` | Generic decisions use crate `ModelRouter`; host health signals remain | PENDING | Routing parity tests host/crate |
| WP-2 | `tool_timeout` implementation | Crate `ToolTimeout` owns timeout mechanics; host only projects config/env | PENDING | Timeout precedence tests |
| WP-2 | `model_council/{council,graph}.rs` | Generic ensemble graph released in tinyagents | PENDING | Upstream PR + offline graph tests |
| WP-3 | legacy `run_turn_engine` and graph escape hatches | All regression assertions exercise the crate turn path | PENDING | `rg OPENHUMAN_AGENT_GRAPH_` history-only |
| WP-4 | host tool trait/adapter artifacts selected by design | Approved tool-model decision preserves security and ungated result types | DESIGN GATE | Successor design document |
| WP-5 | generic seam middlewares | Equivalent crate middleware released and adopted | PENDING | Per-middleware drift rows + parity tests |
| WP-5 | detached subagent registry mechanics | Crate `TaskStore`/`SteeringRegistry` own lifecycle | PENDING | Upstream PR + orchestration tests |
| WP-5 | `agent/progress_tracing.rs` and `progress_tracing/langfuse.rs` | C4 S2-S6 gates pass; journal projection is self-sufficient | BLOCKED | One-release shadow parity and C4 §5 gate |

Deletion totals are reconciled in WP-6 after all rows are terminal. The
original projection is approximately 30k host LOC deleted and 12–15k generic
LOC upstreamed; measured totals, not the estimate, are authoritative.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Status: execution plan (2026-07-04), written after a ground-truth code map of
both the OpenHuman progress surface and the vendored crate observability
primitives. This is the actionable plan for the C4 workstream's July 2026
continuation notes, and it is the gated prerequisite for **doc 03 (V3) Step
5**deleting the `ProviderDelta` bridge and `progress_tracing`.
continuation notes, and it is the gated prerequisite for **S6 below**
deleting the `ProviderDelta` bridge and `progress_tracing`.
Comment on lines +6 to +7

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Align the S5/S6 deletion ownership and parity gate.

Line 6-7 says S6 deletes both ProviderDelta and progress_tracing, but Lines 173-178 assign progress_tracing to S5 and ProviderDelta to S6. Also, the updated “journal projection parity” wording at Lines 174-175 leaves the §5 gate at Lines 182-183 referring to “V3 projection parity.” Update these cross-references before this document governs deletion work.

Also applies to: 174-178

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/tinyagents-full-migration-plan/C4-journal-progress-parity-plan.md`
around lines 6 - 7, Align the migration plan’s deletion ownership and parity
terminology: update the S6 prerequisite statement and the S5/S6 ownership
assignments so `ProviderDelta` and `progress_tracing` have consistent deletion
ownership, then revise the §5 gate to use “journal projection parity” instead of
“V3 projection parity.”


## 1. Corrected architecture (what the map found)

Expand Down Expand Up @@ -171,13 +171,13 @@ span-projection slice.
per-call charged USD awaits a journal-native event. Later delete
`progress_tracing/langfuse.rs` (~825 + tests).
5. **S5 — delete `progress_tracing.rs` + `SpanCollector`** once S3 shadow shows
no divergence for one release **and** V3 projection parity holds (the doc 07
gate). Tick the deletion ledger (~2k incl. tests).
no divergence for one release **and** journal projection parity holds (the
§5 gate). Tick the deletion ledger (~2k incl. tests).
6. **S6 (= V3 Step 5)** — with `AgentProgress` now a journal projection, delete
the legacy `ProviderDelta` bridge in `session/tool_progress.rs` (253) and the
`spawn_delta_forwarder`, since the crate event path is the only producer.

## 5. Gates (doc 07)
## 5. Gates

- `progress_tracing` delete: **C4 shadow parity (S3) for one release AND V3
projection parity.** Langfuse (S4) may land earlier (independent shape parity).
Expand Down
26 changes: 20 additions & 6 deletions docs/tinyagents-inference-migration-plan.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Migrating `src/openhuman/inference/` onto `vendor/tinyagents/`

**Status:** plan (not started)
**Relates to:** #4249 (tinyagents migration), `docs/tinyagents-migration-spec.md` (Phase 2 — model registry / profiles / fallback), `docs/tinyagents-full-migration-plan/`, `docs/tinyagents-drift-ledger.md`
**tinyagents:** 1.7.1, vendored as a git submodule at `vendor/tinyagents/` and path-patched over the crates.io pin (root `Cargo.toml`: `tinyagents = { version = "1.7", features = ["sqlite", "repl"] }` + `[patch.crates-io] tinyagents = { path = "vendor/tinyagents" }`).
**Status:** superseded on 2026-07-22 by
[`tinyagents-migration-plan-2026-07-22.md`](tinyagents-migration-plan-2026-07-22.md).
This document is retained as historical model-layer design detail; its pins,
status, and present-tense inventory are not current.
**Relates to:** #4249 (tinyagents migration),
`docs/tinyagents-migration-plan-2026-07-22.md`,
`docs/tinyagents-full-migration-plan/`, and
`docs/tinyagents-drift-ledger.md`.
**tinyagents audit anchor:** 1.7.1. See the superseding plan for the active pin.

---

Expand Down Expand Up @@ -74,7 +80,10 @@ Verified against 1.7.1 source; re-audit at Phase 0 since the crate moves fast.
- **G3 — Auth-failure signal**: openhuman publishes `DomainEvent::SessionExpired` when a chat attempt fails auth. The crate client must classify 401/expired distinctly (as a `ProviderError` kind) so the host factory can hook it without string-sniffing.
- **G4 — Request dump / wire observability**: `compatible_dump.rs` writes raw request/response dumps for debugging. Upstream a transport-level hook (or confirm the crate's observability exporters cover it) before deleting.
- **G5 — Per-request timeout policy**: `compatible_timeout.rs` semantics vs. what the crate transport exposes. Upstream a per-call timeout on `ModelRequest`/`ProviderSpec` if missing.
- **G6 — BYOK auth styles**: the provider preset catalog (`docs/inference-provider-catalog.md`) supports multiple `AuthStyle`s (headers etc.). Confirm crate `ProviderSpec` can express every style in the catalog; upstream what's missing.
- **G6 — BYOK auth styles**: the authoritative provider catalog
(`src/openhuman/config/schema/cloud_providers.rs`) supports multiple
`AuthStyle`s (headers etc.). Confirm crate `ProviderSpec` can express every
style in the catalog; upstream what's missing.
- **G7 — Repeat-output guard**: `compatible_repeat.rs` (degenerate-repetition detection). Decide: upstream as an optional stream guard, or accept the loss (note #4463 already tracks deleted repeat guards).

Upstream flow: change in `vendor/tinyagents` (submodule working tree) → PR to `tinyhumansai/tinyagents` → publish → bump the crates.io pin in **both** Cargo worlds (root + `app/src-tauri`) and the submodule ref in lockstep. Nothing in openhuman may depend on unpublished vendored-only API at a merge point.
Expand All @@ -87,7 +96,8 @@ Each phase compiles green in both Cargo worlds, keeps ≥80% diff coverage, and

### Phase 0 — Inventory & gap re-audit
- Enumerate every consumer of `Provider` / `ChatRequest` / `ChatResponse` / `ChatMessage` outside `inference/` (151 files) and bucket them: (a) goes through the seam already, (b) direct one-shot `provider.chat(...)` callers (learning, memory, subconscious, screen_intelligence, sentiment, triage…), (c) type-only imports.
- Re-verify §3 gaps against current crate HEAD; file crate issues; update `docs/tinyagents-sdk-gaps.md`.
- Re-verify §3 gaps against current crate HEAD; file crate issues; update
`vendor/tinyagents/docs/sdk-gaps.md`.
- Golden-transcript capture: record request/response wire dumps for the BYOK catalog matrix + Ollama + openhuman backend on the current stack, as fixtures for Phase 2 parity.

**Exit:** disposition table confirmed per-file; crate gap PRs filed.
Expand Down Expand Up @@ -133,7 +143,11 @@ Each phase compiles green in both Cargo worlds, keeps ≥80% diff coverage, and
**Exit:** no ad-hoc prompt/parse loops outside the crate surface.

### Phase 7 — Cleanup, docs, deletion ledger
- Update `inference/README.md`, `gitbooks/developing/architecture/agent-harness.md`, `docs/inference-provider-catalog.md`; add deletions to `docs/tinyagents-full-migration-plan/99-deletion-ledger.md`; refresh `docs/tinyagents-drift-ledger.md`.
- Update `inference/README.md`,
`gitbooks/developing/architecture/agent-harness.md`, and the authoritative
provider catalog in `src/openhuman/config/schema/cloud_providers.rs`; add
deletions to `docs/tinyagents-full-migration-plan/99-deletion-ledger.md`;
refresh `docs/tinyagents-drift-ledger.md`.
- Remove dead re-exports from `inference/mod.rs`; keep temporary `pub use` shims only where a follow-up PR is already open.
- Sweep for stale doc-comments naming `Provider`/`CompatibleProvider`.

Expand Down
Loading
Loading