The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
docs: plan session and orchestration extraction
Steven Enamakel1e0a8c746c83
diff --git a/.sdd-progress.md b/.sdd-progress.mdindex 542380efa5..8cf1cc89d9 100644--- a/.sdd-progress.md+++ b/.sdd-progress.md@@ -5,6 +5,12 @@ Spec: docs/specs/agent-runtime-upstream-boundary.mdAudit: complete (OpenHuman agent tree + TinyAgents/TinyTools/TinyInference capabilities reviewed).Documentation: complete (boundary spec + executable plan + helper packages + ownership waves; final review PASS with no findings).+Profiles and session/orchestration audits: complete. Executable TDD plans are+`docs/plans/migrate-agent-sessions-to-tinyagents-session.md` and+`docs/plans/migrate-agent-orchestration-to-tinyagents.md`; implementation is+pending. They require direct imports with no compatibility shims and preserve+OpenHuman policy/security, persistence-root wiring, BUS/progress/RPC projection,+and concrete execution adapters.Wave 2: complete (direct canonical imports, explicit recursive context, execution-scoped graph bindings including durable resume/retry, registry/definition split, integration fixtures, and full workspace gate; independent Terra reviews resolved).Wave 3: complete in TinyAgents (all ten host capabilities, truthful unary/stream terminal lifecycle, parent-authority-preserving recursion, budget compression/accounting, and upstream Claude provider merge; independent Terra Gate 3 and merge reviews PASS).Wave 4 Phase A: complete at OpenHuman commit 9baad52086 (canonical direct imports, behavior-free facade deletion, host-only conversion/tracing seams retained; independent Terra review PASS).diff --git a/docs/plans/migrate-agent-orchestration-to-tinyagents.md b/docs/plans/migrate-agent-orchestration-to-tinyagents.mdnew file mode 100644index 0000000000..7f70484466--- /dev/null+++ b/docs/plans/migrate-agent-orchestration-to-tinyagents.md@@ -0,0 +1,156 @@+# Extract `tinyagents-orchestration`++Create the correctly spelled `vendor/tinyagents/crates/tinyagents-orchestration`+workspace crate for host-neutral *composition* of agent work. It is not a new+task registry, graph runtime, session database, tool package, or policy layer.++## Non-negotiable boundary++`tinyagents-orchestration` may depend on `tinyagents-harness`,+`tinyagents-graph`, and `tinyagents-session`. Those three crates must not depend+back on it. OpenHuman continues to depend directly on all four where it uses+their APIs. Do not add forwarding modules or re-export moved APIs from+`crate::agent::orchestration`.++Existing owners remain authoritative:++- graph: `DetachedTaskRegistry`, task stores/reconciliation/steering,+ DAG/map-reduce/workspace claims, checkpointing and delegation graph;+- harness: subagents, cancellation/steering, workspace interfaces and git+ worktrees;+- session: durable sessions, run ledger, team/workflow rows and CAS;+- OpenHuman: config, policy/security/approval, concrete execution adapters,+ BUS/progress/chat projection, persistence-root wiring, RPC schemas, tools,+ worktree policy and product prompt/catalog choices.++## Public API++The new crate exposes typed plans and trait seams, never OpenHuman values:++```rust+pub trait TeamLedger: Send + Sync { /* team/member/task/event operations */ }+#[async_trait]+pub trait TeamWorker: Send + Sync {+ async fn run(&self, request: TeamWorkRequest) -> Result<TeamWorkResult, OrchestrationError>;+}++pub trait WorkflowStore: Send + Sync { /* load/upsert workflow snapshots */ }+#[async_trait]+pub trait WorkflowExecutor: Send + Sync {+ async fn execute(&self, request: WorkflowChildRequest,+ cancel: CancellationToken) -> Result<WorkflowChildResult, OrchestrationError>;+ async fn cancel_children(&self, child_ids: &[String]);+}+```++Provide `teams::{TeamService, TeamView, TeamError, run_member_graph}` and+`workflow::{WorkflowDefinition, WorkflowPhase, validate, WorkflowEngine,+WorkflowState, scheduler_graph}`. A `session-ledger` convenience adapter may+wrap `tinyagents_session::run_ledger` with a caller-supplied workspace path;+the host still chooses that path. Safety tier admission, agent lookup, tool+visibility and worktree choice are inputs already authorized by the host, not+crate decisions.++## Cargo files and graph++Add `crates/tinyagents-orchestration/Cargo.toml`, register it in+`vendor/tinyagents/Cargo.toml` default members, and use direct dependencies on+`anyhow`, `async-trait`, `serde`, `serde_json`, `tokio`, `uuid`,+`tinyagents-harness`, `tinyagents-graph`, and `tinyagents-session`. Forward a+single optional `tracing` feature to the three TinyAgents crates. Do not add+`tinytools` unless a public signature needs it, and do not enable graph SQLite+for ordinary workflow state.++## File map++| OpenHuman source | Destination / action |+| --- | --- |+| `agent/orchestration/agent_teams/{types,ops,graph}.rs` | Move generic views/errors, dependency validation/service, and callback member graph to `tinyagents-orchestration/src/teams/`. |+| `agent/orchestration/agent_teams/runtime.rs` | Split generic claim/select/prompt/message-boundary/reconciliation engine to `teams/runtime.rs`; retain OpenHuman root-parent, `run_subagent`, config and projection adapter. |+| `agent/orchestration/workflow_runs/{types,graph}.rs`, pure `ops.rs` | Move to `src/workflow/{types,validate,graph}.rs`. Built-in host catalog and schema wiring stay. |+| `workflow_runs/engine/{state,scheduler,cancel}.rs` | Move to `src/workflow/`. |+| `workflow_runs/engine/{phase_exec,lifecycle}.rs` | Split generic bounded fanout/state machine to crate; keep `Config`, `AgentOrchestrationSession`, origin propagation, root parent, spawn and host persistence adapter. |+| `spawn_parallel_graph/request.rs` | Move only typed request validation to `src/parallel/request.rs`; do not move tool JSON parsing unless it becomes a typed boundary. |+| `spawn_parallel_graph/graph.rs` | Keep only a callback coordinator if it adds value; otherwise delete it and call graph `parallel::map_reduce` directly. |+| `spawn_parallel_graph/{types,staging,dispatch,workers,collect,run}.rs` | Keep OpenHuman: definition/tool-policy inspection, worktree prep, execution, AgentProgress and file-state projection. |+| `worktree.rs` aliases | Delete aliases and import `tinyagents_harness::workspace::{create_git_worktree, GitWorktreeBaseRef, ...}` directly. Keep only OpenHuman's BUS/policy-id adapter and schemas. |+| `ops.rs`, `types.rs`, `delegation.rs`, `parent_context/**`, `running_subagents/**`, `subagent_sessions/**`, `background_*`, `run_ledger_finalize.rs`, `subagent_events.rs`, `command_center/**`, `subagent_control.rs`, all `tools/**`, all RPC schemas | Keep in OpenHuman. |++## TDD slices++### O1 — crate skeleton and architecture gate++**RED:** Add a dependency-boundary test proving the new crate has no OpenHuman+dependency and no reverse edge from graph/harness/session. Add a compilation+test importing its empty public modules.++**GREEN:** Add the manifest, `lib.rs`, documentation and feature forwarding.+Verify `cargo metadata --manifest-path vendor/tinyagents/Cargo.toml --no-deps`+and `cargo test -p tinyagents-orchestration`.++### O2 — team service and member graph++**RED:** Port `agent_teams/graph_tests.rs` and generic `ops_tests.rs` cases to+the new crate with a fake `TeamLedger`/`TeamWorker`: duplicate names, unknown+member/dependency, self/cycle rejection, ordered messages, claim race result,+quality-gated completion, complete route, failed route, and worker engine error.++**GREEN:** Implement typed team service and callback graph. Add the optional+session-ledger adapter only after the trait suite is green.++### O3 — workflow definitions and scheduler++**RED:** Add fake-store/executor tests for duplicate/missing/cyclic/empty+phases, invalid concurrency, deterministic dependency order, upstream context,+synthesis fallback, scheduler topology and no-runnable failure.++**GREEN:** Move workflow definitions, validation, state helpers and scheduler+graph. Keep host safety-tier authorization outside the generic plan.++### O4 — workflow engine fanout, cancel and resume++**RED:** Port the behavior from `workflow_runs/engine_tests.rs`: bounded+concurrency, global child-cap failure, partial-output failure, cancellation+during a phase, terminal persistence, and resume skipping complete phases.++**GREEN:** Implement `WorkflowEngine<S,E>` using graph `map_reduce` and a+`CancellationToken`; it returns a future for the host to spawn in its own+origin/parent context.++### O5 — OpenHuman adapters and direct import cutover++**RED:** Preserve OpenHuman integration tests for team worker execution,+workflow policy denial, BUS/progress lifecycle, durable run rows and RPC wire+shapes. Add grep/checker coverage rejecting moved API re-exports.++**GREEN:** Implement minimal host adapters, migrate direct consumers and+topology registration, delete moved code and aliases in the same change.++### O6 — parallel/worktree cleanup++**RED:** Preserve `spawn_parallel_agents` policy tests and dirty-worktree+removal/refusal tests.++**GREEN:** Move only typed neutral request logic; replace all worktree aliases+with direct harness imports. Keep policy/worktree/BUS behavior host-side.++## Verification and PR order++For each TinyAgents slice run:++```bash+cargo test --manifest-path vendor/tinyagents/Cargo.toml -p tinyagents-orchestration+cargo test --manifest-path vendor/tinyagents/Cargo.toml -p tinyagents-graph -p tinyagents-session+cargo check --manifest-path vendor/tinyagents/Cargo.toml --workspace+```++For the host cutover run `pnpm debug rust agent_team`, `pnpm debug rust+workflow_run`, `pnpm debug rust spawn_parallel_agents`, `cargo check+--manifest-path Cargo.toml`, `pnpm rust:layout`, and `pnpm docs:check`. Use+`scripts/ci-cancel-aware.sh` for long workspace gates and never export+`CARGO_TARGET_DIR`.++Land in order: (1) session migration PR where its API is needed; (2) TinyAgents+new-crate PR; (3) OpenHuman gitlink update and direct-import cutover PR. Each+submodule branch/PR is against canonical upstream before the parent gitlink is+published; no nested worktrees, squashing, aliases or shims.diff --git a/docs/plans/migrate-agent-sessions-to-tinyagents-session.md b/docs/plans/migrate-agent-sessions-to-tinyagents-session.mdnew file mode 100644index 0000000000..077b29302b--- /dev/null+++ b/docs/plans/migrate-agent-sessions-to-tinyagents-session.md@@ -0,0 +1,145 @@+# Migrate host-independent sessions to `tinyagents-session`++This plan moves durable, host-neutral agent-session mechanics into+`vendor/tinyagents/crates/tinyagents-session`. It is intentionally separate+from agent execution: the session crate is queryable persistence, not a model+runner. Every consumer imports `tinyagents_session` directly; neither+OpenHuman nor `tinyagents-harness` may retain a forwarding module, alias, or+compatibility re-export.++## Boundary++Move the transcript model, JSONL codec, transcript/history interfaces,+workspace-relative transcript discovery, append/compaction mechanics, and+generic retention/import conversion. The target crate already owns SQLite+session records, FTS, retention, and the run ledger.++Keep in OpenHuman: `Config` and workspace selection; `Agent` construction and+model/tool execution; `ChatMessage`/provider conversion; prompt-injection and+security policy; memory extraction; BUS/progress/RPC/UI projection; backend+import selection; and every product-specific transcript field or migration.++In particular, do not move `session_memory`, `task_session`, web-chat's live+session cache, session-import controller schemas, `Agent::run_single`, or+anything in `turn/` that constructs a host turn. The target must never depend+on `openhuman`, `tinyagents-graph`, provider credentials, or product prompts.++## Target API and dependencies++Add these public modules to `tinyagents-session`:++```text+transcript::{+ TranscriptMeta, SessionTranscript, DisplaySessionTranscript,+ TranscriptRecord, TurnUsage, MessageUsage, ChatHistory,+ TranscriptHistory, TranscriptRead, TranscriptLocator,+ read_transcript, read_transcript_display, write_transcript,+ append_turn, compact_context, transcript_path, latest_for_agent,+ root_for_thread, thread_scoped_for_agent+}+```++Use `tinyinference_llm::message::Message` and its tool-call representation for+the persisted model transcript. If an OpenHuman-only field is needed, expose a+small caller-owned metadata JSON value rather than naming `ChatMessage` or an+OpenHuman type. Keep stable JSONL `kind` tags forward-compatible: unknown+records are skipped, not fatal. `tinyagents-session` may depend on+`tinyinference-llm`, `tinyagents-harness` only for its error/`ChatHistory`+contract (or relocate that contract to session to avoid an upward dependency),+serde, serde_json, chrono and std I/O. It must not depend on graph or the new+orchestration crate.++OpenHuman replaces its local types and helpers with direct imports, then+implements only an adapter at the existing host boundary where conversion from+`ChatMessage` to crate-native messages is unavoidable. Do not retain+`agent::harness::session::transcript::*` as a public facade.++## File map++| Current OpenHuman source | Destination / action |+| --- | --- |+| `agent/harness/session/transcript/{types,jsonl,metadata,paths,reader,writer,legacy_md,markdown,thread_lookup}.rs` | Move/split into `tinyagents-session/src/transcript/`; preserve on-disk JSONL and legacy Markdown reader behavior. |+| `agent/harness/session/transcript.rs` | Delete after consumers import `tinyagents_session::transcript` directly. |+| `agent/harness/session/transcript_history.rs` | Move generic history/read/locator traits and file implementation to `tinyagents-session/src/transcript/history.rs`; keep any OpenHuman message conversion adapter locally. |+| `agent/harness/session/runtime/resume.rs` | Split pure transcript-to-model replay/deduplication into session; keep `Agent` mutation and host message-log fallback in OpenHuman. |+| `agent/session_import/{convert,ops,live}.rs` | Move only pure descriptor/transcript conversion and generic source iteration; retain OpenHuman namespaces, controller/live backend wiring, run-ledger links, and memory import. |+| `agent/harness/session/{mod.rs,types.rs,builder/**,runtime/**,turn/**,tool_progress.rs,migration.rs}` | Keep: host session construction/execution, tools, policy, memory, progress, and migration policy. |+| `agent/context/session_memory.rs`, `agent/task_session.rs`, `web_chat/**`, `threads/**` | Keep. |+| All transcript/session-import tests named below | Port their host-independent cases to the matching TinyAgents module; retain OpenHuman adapter/integration tests. |++## TDD slices++### S1 — crate-native transcript model and codec++**RED:** Port `transcript_roundtrip_and_paths_tests.rs`,+`transcript_forward_compat_tests.rs`, `transcript_tests.rs`, and+`transcript_thread_and_append_tests.rs` into+`tinyagents-session/src/transcript/test.rs`. Assert byte-stable JSONL round+trip; tool calls, tool results, reasoning and usage survive; unknown kinds are+ignored; malformed required records fail; append writes only deltas; and path+derivation is deterministic.++**GREEN:** Add `transcript/{types,jsonl,metadata,paths,reader,writer}.rs` and+the public API above. Use crate-native message types. Do not change established+OpenHuman file bytes in this slice.++### S2 — history, compaction, and discovery++**RED:** Port `transcript_history_tests.rs` and the relevant+`session_thread_resume*_tests.rs` cases. Test model-context rather than display+replay, compaction without destructive rewrite, clear semantics, latest-agent+lookup, root-thread lookup, thread-scoped lookup, and concurrent append safety.++**GREEN:** Move `TranscriptHistory`, `TranscriptRead`, `TranscriptLocator`,+and file implementation to `tinyagents-session::transcript::history`. Make the+history trait a direct dependency of the harness/session user; no OpenHuman+trait wrapper remains.++### S3 — replay and import conversion++**RED:** Add crate tests for replaying full-fidelity tool/reasoning messages,+dropping only the duplicated trailing user input, empty/missing transcript+behavior, legacy Markdown read-only import, and deterministic descriptor+conversion. Port only pure cases from `session_import/ops_tests.rs` and+`live_tests.rs`.++**GREEN:** Export pure replay/descriptor utilities from session. Keep+OpenHuman's `Agent::seed_resume_from_messages`, external conversation fallback,+backend import and memory namespace decisions as thin host calls around them.++### S4 — OpenHuman direct-import cutover++**RED:** Add OpenHuman adapter tests proving its `ChatMessage` conversion+preserves tool calls/reasoning/usage and that an old transcript resumes without+loss. Add a boundary check that fails on production imports from+`agent::harness::session::transcript` after migration.++**GREEN:** Update `agent/harness/session/**`, `agent/session_import/**`,+`agent/tinyagents/{journal,reaper,turn_runner}.rs`, and direct consumers to+import `tinyagents_session::transcript::*`. Delete moved source and tests; do+not add `pub use` compatibility paths.++## Verification++Run after each slice:++```bash+cargo test --manifest-path vendor/tinyagents/Cargo.toml -p tinyagents-session transcript+cargo test --manifest-path vendor/tinyagents/Cargo.toml -p tinyagents-session+pnpm debug rust session+cargo check --manifest-path Cargo.toml+pnpm rust:layout+```++Before the PR, run `scripts/ci-cancel-aware.sh cargo test --manifest-path+vendor/tinyagents/Cargo.toml --workspace`, `pnpm docs:check`, and the direct-+import/boundary grep. Do not export `CARGO_TARGET_DIR`.++## Integration order++1. Land the TinyAgents session-crate PR, including its direct `tinyinference`+ dependency if required.+2. Update the OpenHuman `vendor/tinyagents` gitlink to that landed/reviewed+ commit, cut over consumers, delete old paths, and open the OpenHuman PR.+3. The orchestration extraction may depend on the landed session API; do not+ start its session-backed adapter before S1–S3 API names are fixed.