Repository navigation
agent/: move harness code to tinyagents (incl. new tinyagents-hooks crate), relocate product code, shrink agent/ to wiring #7929
Description
Summary
crates/openhuman-core/src/agent/ is about 79k non-test lines. Most of it should be wiring: tinyagents port implementations plus turn composition. tinyagents (vendor/tinyagents) now ships nearly the whole harness. This issue records a file-by-file evaluation of every non-test file under agent/, plus src/hooks/.
Ownership rule. tinyagents owns everything about the harness, hooks included. OpenHuman owns tool implementations, security and approvals, the storage implementation, product RPC, the TinyHumans backend, config and product copy.
Verdicts
- DELETE: a shim, re-export, dead code or duplicate. Callers import upstream directly.
- UPSTREAM: generic harness logic. Move it to the named tinyagents crate and module.
- REIMPLEMENT: OpenHuman reimplements something upstream already has. Replace it with upstream plus thin host callbacks; the listed gaps go upstream first.
- RELOCATE: product or host code that isn't harness wiring. Move it out of
agent/tosrc/<domain>/. - KEEP: genuine wiring or a port implementation.
New crate: tinyagents-hooks (tinyhumansai/tinyagents#470; host adoption #7949)
One home for every hook. It depends on tinyagents-harness, and tinyagents-runtime depends on it. Contents:
- Typed in-process
ToolHook<Ctx>with its middleware, theToolHookDecision, and aHookIdentityextractor.ToolHookDecisionis unified with the command-hook allow/deny/ask/updated_input/additional_context vocabulary. This comes fromagent/hooks.rsandagent/tinyagents/middleware/embedder_hooks.rs. - The
hooks.jsonengine, moved fromtinyagents-runtime/src/command_hooks. - Stop hooks, moved from
harness/.../library/stop_hooksandstop_latch, plus the stockBudgetStopHookandGoalBudgetStopHook. - Lifecycle hooks, moved from
harness/.../library/lifecycle_hooks. - Post-turn hooks.
PostTurnHookis retired in favour ofLearningSink, withTurnSummaryextended by per-tool outcomes. HookScopeandFnSessionHooks.
OpenHuman keeps only the global embedder registries and its HookIdentity impl. openhuman-embed re-exports the upstream types under their current names.
Totals (≈80.6k non-test lines evaluated: all of agent/ plus src/hooks/)
| Verdict | Lines | Share |
|---|---|---|
| KEEP | 22,238 | 28% |
| RELOCATE | 21,256 | 26% |
| REIMPLEMENT | 18,168 | 23% |
| UPSTREAM | 15,232 | 19% |
| DELETE | 3,683 | 5% |
If every row lands, agent/ drops from about 79k to about 22k lines of wiring. That figure is still inflated by oversized KEEP files, which should be split: session_host/builder/factory.rs 965, runtime_session.rs 1065, run_context.rs 749, turn_exec.rs 696, runtime/accessors.rs 657 (_for_test accessors). About 21k lines move to their proper OpenHuman domains, and about 15k move into tinyagents.
New OpenHuman domains proposed (RELOCATE targets)
src/agent_runs/: orchestration product RPC. Covers subagent_control, worktree_schemas, command_center, agent_teams/schemas, workflow_runs/{schemas,ops}, replay,agent/schemas.rsand context_breakdown.src/agent_registry/:registry/,library/,harness/host_definition.rs, builtin prompt copy.- Existing domains:
src/artifacts/,src/attachments/,src/triage/(plus the trigger prompts),src/plan_review/src/storage/(session_store, session_import),src/sessions/(session_db)core/agent_cli(debug)src/inference/(model.rs, turn_models.rs, reasoning.rs)src/integrations/(prelude_integrations, recorded_tools, connected_identities, announcement copy)src/memory/(memory_ingest),src/threads/(worker_thread, worker_mirror, run_mode)src/security/(turn_origin, provider_open secure_open),src/channels/(channels_prompt)src/modules/tinybox(host_runtime),src/web_chat/(turn_backstop)
RPC namespace strings do not change; they are wire contracts.
Sub-issues (tracker)
Work order: 1. bugs + deletes → 2. relocations (one domain per PR, OpenHuman-only) → 3. upstream tinyagents work (start with tinyagents-hooks) → 4. host adoption (each blocked on its upstream issue). Each upstream item follows the same chain: tinyagents PR, then tag, then an OpenHuman gitlink bump plus deletion of the host copy.
1. Bugs found in the audit
- delegate_graph tool reports errors as
delegate:#7931 delegate_graph tool reports errors asdelegate: - Background completions record awaiting_input as a completion, taking the dedupe slot #7932 Background completions record awaiting_input as a completion, taking the dedupe slot
- triage routing docs say the local path is removed, but the chain still builds a local provider #7933 triage routing docs say the local path is removed, but the chain still builds a local provider
1. Deletes (OpenHuman-only)
- Delete dead tinyagents/host adapters (context composer, model resolver, learning sink, progress sink) #7934 Delete dead tinyagents/host adapters (context composer, model resolver, learning sink, progress sink)
- Delete agent/ shims and duplicate copies of upstream code senamakel/openhuman#140 Delete agent/ shims and duplicate copies of upstream code
- Move test-only code out of agent/ production builds #7936 Move test-only code out of agent/ production builds
2. Relocations out of agent/ (OpenHuman-only, mechanical; RPC names unchanged)
- Relocate orchestration product RPC to a new src/agent_runs/ domain #7937 Relocate orchestration product RPC to a new src/agent_runs/ domain
- Relocate agent registry/definitions to src/agent_registry/ #7938 Relocate agent registry/definitions to src/agent_registry/
- Relocate agent/artifacts to src/artifacts/ #7939 Relocate agent/artifacts to src/artifacts/
- Relocate agent/attachments to src/attachments/ (secure_open to security) #7940 Relocate agent/attachments to src/attachments/ (secure_open to security)
- Relocate agent/triage to src/triage/ #7941 Relocate agent/triage to src/triage/
- Relocate agent/plan_review to src/plan_review/ #7942 Relocate agent/plan_review to src/plan_review/
- Relocate session_store / session_db / session_import out of agent/ #7943 Relocate session_store / session_db / session_import out of agent/
- Relocate agent/debug to core/agent_cli #7944 Relocate agent/debug to core/agent_cli
- Relocate model construction and reasoning out of agent/tinyagents to src/inference/ #7945 Relocate model construction and reasoning out of agent/tinyagents to src/inference/
- Relocate integration logic out of session_host/prompts to src/integrations/ #7946 Relocate integration logic out of session_host/prompts to src/integrations/
- Relocate memory ingest and worker-thread/run-mode code to src/memory and src/threads #7947 Relocate memory ingest and worker-thread/run-mode code to src/memory and src/threads
- Relocate remaining product files out of agent/ (turn_origin, channels prompt, host_runtime, progress, product tools) #7948 Relocate remaining product files out of agent/ (turn_origin, channels prompt, host_runtime, progress, product tools)
3. Upstream: tinyagents / tinytools
- tinyagents-hooks: new crate holding every hook type tinyagents#470 tinyagents-hooks: new crate holding every hook type
- orchestration: SubAgentTool through SubagentDriver, multi-target delegation, durable reusable sessions, parallel tool tinyagents#471 orchestration: SubAgentTool through SubagentDriver, multi-target delegation, durable reusable sessions, parallel tool
- orchestration: FileSubagentPersistence, shared InFlight, result policy helpers, awaiting-user contract tinyagents#472 orchestration: FileSubagentPersistence, shared InFlight, result policy helpers, awaiting-user contract
- tasks/orchestration: completion delivery loop, CompletionRouter registry, abort guard, live-then-durable wait/resolve tinyagents#473 tasks/orchestration: completion delivery loop, CompletionRouter registry, abort guard, live-then-durable wait/resolve
- orchestration: workflow run supervisor (start/stop/resume) and TeamService::start_member executor seam tinyagents#474 orchestration: workflow run supervisor (start/stop/resume) and TeamService::start_member executor seam
- harness: turn close/checkpoint module (grounded close, close-repair, CloseVerdict) tinyagents#475 harness: turn close/checkpoint module (grounded close, close-repair, CloseVerdict)
- runtime/session: codec reconcile, managed-tools algebra, tool-surface refresh, rebindable stores, usage rollup tinyagents#476 runtime/session: codec reconcile, managed-tools algebra, tool-surface refresh, rebindable stores, usage rollup
- observability: trace_export span collector folding AgentEvent (revisit host-owns-collector boundary) tinyagents#477 observability: trace_export span collector folding AgentEvent (revisit host-owns-collector boundary)
- harness prompt: stable/context/volatile cache tiers, dynamic sections, AGENTS.md loader, dialect prompt dispatch tinyagents#478 harness prompt: stable/context/volatile cache tiers, dynamic sections, AGENTS.md loader, dialect prompt dispatch
- harness middleware: no_progress callbacks, policy-gate session ceiling, output-ladder shell, transcript snapshot, outcome capture, journal fan-out tinyagents#479 harness middleware: no_progress callbacks, policy-gate session ceiling, output-ladder shell, transcript snapshot, outcome capture, journal fan-out
- harness host/runtime: small generic moves from OpenHuman (HostedError, routes resolver, DenialRenderer, ModelBudget, classifier) tinyagents#480 harness host/runtime: small generic moves from OpenHuman (HostedError, routes resolver, DenialRenderer, ModelBudget, classifier)
- harness tools: use_skill live-parent redispatch, plan_exit tool, artifact offload materialize tinyagents#481 harness tools: use_skill live-parent redispatch, plan_exit tool, artifact offload materialize
- harness multimodal: request-preparing ChatModel wrapper, non-vision text fallback, marker helper gaps tinyagents#482 harness multimodal: request-preparing ChatModel wrapper, non-vision text fallback, marker helper gaps
- runtime/session transcript: TranscriptMessage <-> Message helpers and legacy {role,content} row serde tinyagents#483 runtime/session transcript: TranscriptMessage <-> Message helpers and legacy {role,content} row serde
- harness structured/retry: parse_lenient last-object option and persistent per-key failover breaker tinyagents#484 harness structured/retry: parse_lenient last-object option and persistent per-key failover breaker
- status: classify web_fetch HTTP-status results (from OpenHuman fetched_site middleware) tinytools#72 status: classify web_fetch HTTP-status results (from OpenHuman fetched_site middleware)
4. Host adoption (REIMPLEMENT rows; each blocked on upstream)
- Adopt tinyagents-hooks: shrink agent/hooks.rs to registries, delete hook adapters #7949 Adopt tinyagents-hooks: shrink agent/hooks.rs to registries, delete hook adapters (blocked by tinyagents-hooks: new crate holding every hook type tinyagents#470)
- Replace orchestration/tools subagent tools with upstream SubAgentTool/JobsTool/MessageTool/OrchestrationTool senamakel/openhuman#141 Replace orchestration/tools subagent tools with upstream SubAgentTool/JobsTool/MessageTool/OrchestrationTool (blocked by orchestration: SubAgentTool through SubagentDriver, multi-target delegation, durable reusable sessions, parallel tool tinyagents#471, orchestration: FileSubagentPersistence, shared InFlight, result policy helpers, awaiting-user contract tinyagents#472, tasks/orchestration: completion delivery loop, CompletionRouter registry, abort guard, live-then-durable wait/resolve tinyagents#473)
- Shrink subagent_host onto upstream SubagentDriver, FileSubagentPersistence and ResultPolicy senamakel/openhuman#142 Shrink subagent_host onto upstream SubagentDriver, FileSubagentPersistence and ResultPolicy (blocked by orchestration: FileSubagentPersistence, shared InFlight, result policy helpers, awaiting-user contract tinyagents#472)
- Adopt upstream detached completions, delivery loop, workflow supervisor and teams executor senamakel/openhuman#143 Adopt upstream detached completions, delivery loop, workflow supervisor and teams executor (blocked by tasks/orchestration: completion delivery loop, CompletionRouter registry, abort guard, live-then-durable wait/resolve tinyagents#473, orchestration: workflow run supervisor (start/stop/resume) and TeamService::start_member executor seam tinyagents#474, Background completions record awaiting_input as a completion, taking the dedupe slot #7932)
- Collapse session_host double driver and adopt upstream TurnControls, tool-surface refresh, codec reconcile senamakel/openhuman#144 Collapse session_host double driver and adopt upstream TurnControls, tool-surface refresh, codec reconcile (blocked by harness: turn close/checkpoint module (grounded close, close-repair, CloseVerdict) tinyagents#475, runtime/session: codec reconcile, managed-tools algebra, tool-surface refresh, rebindable stores, usage rollup tinyagents#476)
- Feed Langfuse/OTLP traces from upstream collector; delete progress_tracing collector and journal projection senamakel/openhuman#145 Feed Langfuse/OTLP traces from upstream collector; delete progress_tracing collector and journal projection (blocked by observability: trace_export span collector folding AgentEvent (revisit host-owns-collector boundary) tinyagents#477)
- Render system prompt through upstream harness::prompt sections and tiers senamakel/openhuman#146 Render system prompt through upstream harness::prompt sections and tiers (blocked by harness prompt: stable/context/volatile cache tiers, dynamic sections, AGENTS.md loader, dialect prompt dispatch tinyagents#478)
- Reduce agent/tinyagents middleware to host callbacks over upstream no_progress, policy gate, output ladder senamakel/openhuman#147 Reduce agent/tinyagents middleware to host callbacks over upstream no_progress, policy gate, output ladder (blocked by harness middleware: no_progress callbacks, policy-gate session ceiling, output-ladder shell, transcript snapshot, outcome capture, journal fan-out tinyagents#479)
- Delete host copies of small generic pieces once upstream lands (routes, resolver, denial, budget, transcript, tools) senamakel/openhuman#148 Delete host copies of small generic pieces once upstream lands (routes, resolver, denial, budget, transcript, tools) (blocked by harness host/runtime: small generic moves from OpenHuman (HostedError, routes resolver, DenialRenderer, ModelBudget, classifier) tinyagents#480, harness tools: use_skill live-parent redispatch, plan_exit tool, artifact offload materialize tinyagents#481, runtime/session transcript: TranscriptMessage <-> Message helpers and legacy {role,content} row serde tinyagents#483, status: classify web_fetch HTTP-status results (from OpenHuman fetched_site middleware) tinytools#72)
- Triage: use parse_lenient and harness failover instead of hand-rolled JSON/error/breaker logic senamakel/openhuman#149 Triage: use parse_lenient and harness failover instead of hand-rolled JSON/error/breaker logic (blocked by harness structured/retry: parse_lenient last-object option and persistent per-key failover breaker tinyagents#484, triage routing docs say the local path is removed, but the chain still builds a local provider #7933)
- Shrink agent/multimodal.rs and attachments provider onto harness multimodal senamakel/openhuman#150 Shrink agent/multimodal.rs and attachments provider onto harness multimodal (blocked by harness multimodal: request-preparing ChatModel wrapper, non-vision text fallback, marker helper gaps tinyagents#482)
- Load builtin and custom agent definitions through tinyagents-definition senamakel/openhuman#151 Load builtin and custom agent definitions through tinyagents-definition (blocked by Relocate agent registry/definitions to src/agent_registry/ #7938)
Evaluation: orchestration/ and subagent_host/ (23,421 lines)
Tally: KEEP 4,171 · DELETE 364 · REIMPLEMENT 11,050 · UPSTREAM 4,957 · RELOCATE 2,879
agent/orchestration/ (4728 lines, 5640 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 80 | KEEP | — | Module root and re-exports. Shrinks as the children move out. |
| types.rs | 66 | DELETE | tinyagents_orchestration::subagent::{SubAgentJob, SubAgentJobStatus} |
DTOs used only by AgentOrchestrationSession. They go when ops.rs moves onto upstream jobs. |
| background_completions.rs | 712 | REIMPLEMENT | tinyagents_tasks::CompletionRouter + subagent::record_detached_completion |
One router cached per workspace with in-memory fallback. Gaps: upstream router registry, deleted-thread marker, thread stop/resume, tenant scoping. |
| background_delivery.rs | 749 | UPSTREAM | tinyagents-tasks completions::delivery |
Generic loop: debounce, batch claim, backoff, give-up, boot recovery. Seams: is_busy, delivery turn, undelivered writer. |
| busy_guard.rs | 127 | UPSTREAM | tinyagents-tasks completions::delivery |
RAII guard for parent turns in flight, gating delivery. The tenant key becomes a seam. |
| completion_notice.rs | 223 | KEEP | — | CompletionFormatter impl. OpenHuman's wording is product copy. |
| completion_owners.rs | 93 | KEEP | — | Maps an SaaS profile to a CoreContext. Tenancy is OpenHuman-only. |
| completion_target.rs | 176 | REIMPLEMENT | subagent::DetachedCompletionTarget |
Gaps: upstream skips awaiting-input records; test-workspace helpers sit in prod code. |
| delegation.rs | 305 | UPSTREAM | tinyagents-graph delegation |
The stage prompts and the APPROVE parser are generic. Only the run_subagent worker closure stays. |
| delivery_drain.rs | 143 | UPSTREAM | tinyagents-tasks completions::delivery |
Drain timing is generic. Seam: a fence trait over storage::fence::LeaseFence. |
| fleet_tools.rs | 115 | UPSTREAM | tinyagents-orchestration subagent::role |
Visibility of fleet-control tools from ToolScope belongs with SUBAGENT_JOBS_TOOL. |
| ops.rs | 673 | REIMPLEMENT | subagent::SubAgentJobRegistry / workflow::WorkflowChildRegistration |
Spawn/wait/abort over DetachedTaskRegistry. Gaps: DomainEvent bridge, progress fan-out, definition lookup. |
| run_ledger_finalize.rs | 122 | UPSTREAM | tinyagents-orchestration detached::spawn_status_watcher |
The upstream watcher should write the run ledger itself (to_run_status). |
| running_subagents.rs | 81 | KEEP | — | Module root for the host's registry instance. |
| spawn_parallel.rs | 44 | KEEP | — | Module declarations. |
| subagent_control.rs | 293 | RELOCATE | src/agent_runs/ |
subagent_cancel / steer RPC controllers. |
| subagent_events.rs | 119 | KEEP | — | The single DomainEvent publisher. Becomes a tinyagents-hooks subscriber later. |
| tools.rs | 96 | KEEP | — | Tool module root, plus live_parent_run_context. |
| worktree.rs | 183 | REIMPLEMENT | harness::workspace::GitWorktreeIsolation + tinyagents-hooks |
Decorator that only stamps a policy id and publishes events. Gaps: id prefix, workspace lifecycle hook. |
| worktree_schemas.rs | 328 | RELOCATE | src/agent_runs/ |
worktree_* RPC controllers. |
agent/orchestration/agent_teams/ (1279 lines, 615 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 31 | RELOCATE | src/agent_runs/agent_teams/ |
Re-export root. |
| runtime.rs | 611 | REIMPLEMENT | teams::{TeamService, run_member_graph_with} |
Bypasses TeamService. Gap: an upstream start_member with an executor seam. |
| schemas.rs | 637 | RELOCATE | src/agent_runs/agent_teams/ |
Eleven agent_team_* RPC controllers. |
agent/orchestration/background_completions/ (80 lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| thread_index.rs | 80 | KEEP | — | Index from thread/session to workspace, keyed by tenant. Depends on DispatchCtx. |
agent/orchestration/background_delivery/ (54 lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| slot.rs | 54 | UPSTREAM | tinyagents-tasks completions::delivery |
Lease for one delivery turn per thread. |
agent/orchestration/command_center/ (252 lines, 126 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 17 | RELOCATE | src/agent_runs/command_center/ |
Re-export root. |
| schemas.rs | 235 | RELOCATE | src/agent_runs/command_center/ |
agent_work_* RPC over run_ledger::command_center. |
agent/orchestration/parent_context/ (179 lines, 103 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| builder.rs | 169 | KEEP | — | Builds the root ParentExecutionContext. Host wiring. |
| mod.rs | 10 | DELETE | — | Export-only shim. |
agent/orchestration/running_subagents/ (1299 lines; 1802 test lines sit beside it)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| cancel.rs | 255 | REIMPLEMENT | detached::{cancel_for_thread, distinct_parent_threads, FinishedOutcome} |
Gaps: tenant control_admits, workspace admission, metadata on cancelled runs. |
| registry.rs | 270 | KEEP | — | Host-owned DetachedTaskRegistry instance plus identity metadata and tenant key. |
| resolve.rs | 88 | REIMPLEMENT | detached::{task_id_for_session, resume_ref_for_task, resume_ref_from_record} |
Gap: a live-then-durable fallback combinator. |
| roster.rs | 159 | KEEP | — | The [active_subagents] prompt block. Turn composition. |
| steering.rs | 201 | REIMPLEMENT | detached::{steer_detached, steering_command_for_lane, queue_lane_name} |
Copies upstream line for line, including the prompt prefixes. |
| task_ledger.rs | 272 | KEEP | — | Chooses where the store lives, plus the shared-storage reconcile guard. |
| wait.rs | 54 | REIMPLEMENT | detached::{wait_detached, record_to_wait_outcome} |
Gaps: live-then-durable fallback, workspace admission. |
agent/orchestration/spawn_parallel/ (1519 lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| collect.rs | 245 | REIMPLEMENT | parallel::{Collected, overlap_warnings, RunHooks::on_finish} |
Projects progress by hand. Gap: stale parent-read annotation. |
| dispatch.rs | 349 | REIMPLEMENT | parallel::{Preflight, RunHooks::on_start} |
Gap: an async preflight step for worktree isolation. |
| run.rs | 196 | KEEP | — | Entry wiring. |
| staging.rs | 394 | KEEP | — | AdmissionPolicy impl. |
| types.rs | 105 | KEEP | — | Host payload P and result types. |
| workers.rs | 230 | KEEP | — | Branch executor given to parallel::run. |
agent/orchestration/subagent_sessions/ (713 lines, 405 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 18 | DELETE | — | Re-export shim. |
| ops.rs | 266 | UPSTREAM | tinyagents-orchestration subagent::sessions |
Generic durable reusable-session logic. Upstream SubAgentSession is in-memory only. |
| store_documents.rs | 206 | UPSTREAM | tinyagents-orchestration DriverSubagentSessionStore |
Already written against tinystoragedrivers. |
| store.rs | 59 | KEEP | — | Opens OpenHuman's storage scope and imports the legacy file. |
| types.rs | 164 | UPSTREAM | tinyagents-orchestration subagent::sessions |
Session, selector and reuse types. |
agent/orchestration/tools/ (7137 lines, 4706 test lines; the empty parameters/ dir can be deleted)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| archetype_delegation.rs | 318 | REIMPLEMENT | subagent::SubAgentTool |
Gaps: envelope fields, Hidden exposure, blocking mapped to the mode field. |
| awaiting_user.rs | 70 | UPSTREAM | tinyagents-orchestration subagent |
[SUBAGENT_AWAITING_USER] is the harness pause contract. |
| close_subagent.rs | 184 | REIMPLEMENT | SubAgentJobsTool cancel |
Gap: also closes the durable session. |
| collapsed_delegation.rs | 431 | REIMPLEMENT | SubAgentTool |
Gap: a multi-target SubAgentTool (agent enum). |
| continue_subagent.rs | 677 | REIMPLEMENT | SubagentRequest::continue_with_key via SubagentDriver |
Gaps: durable-session lookup, worker-thread append, re-pause envelope. |
| delegate_graph.rs | 280 | UPSTREAM | tinyagents-graph delegation (DelegationTool) |
Needs an upstream tool with a stage-worker seam. Error strings say delegate:. |
| dispatch.rs | 655 | REIMPLEMENT | SubAgentTool inline/background |
Gap: fall back to inline when there is no delivery thread. |
| dispatch_outcomes.rs | 103 | UPSTREAM | subagent::result_policy |
Outcome framing and unexecuted-stub detection. |
| list_subagents.rs | 249 | REIMPLEMENT | SubAgentJobsTool / OrchestrationTool List |
Gap: overlay of durable session and task status. |
| spawn_async_subagent_args.rs | 73 | REIMPLEMENT | SubAgentTool args |
— |
| spawn_async_subagent_execute.rs | 747 | REIMPLEMENT | SubAgentTool background + spawn_status_watcher_with_completions |
Hand-rolled register, watcher and completion. Gaps: session reuse, delivery thread, tenant admission, worker thread. |
| spawn_async_subagent_results.rs | 99 | REIMPLEMENT | SubAgentTool result |
— |
| spawn_async_subagent.rs | 633 | REIMPLEMENT | SubAgentTool (background) |
Gap: spec scoped to the allowlist. |
| spawn_parallel_agents.rs | 283 | UPSTREAM | tinyagents-orchestration parallel (tool) |
Generic fan-out tool. Host supplies AdmissionPolicy and the executor. |
| spawn_subagent_parameters.rs | 78 | REIMPLEMENT | SubAgentTool params |
— |
| spawn_subagent.rs | 234 | REIMPLEMENT | SubAgentTool (inline) |
Gaps: worker-thread persistence, failure copy. |
| spawn_subagent_tool_impl.rs | 578 | REIMPLEMENT | SubAgentTool (inline) |
Same gaps. |
| spawn_worker_thread.rs | 484 | RELOCATE | src/tools/impl/threads/ |
Product tool for persisted worker threads. |
| steer_subagent.rs | 207 | REIMPLEMENT | SubAgentMessageTool / OrchestrationTool Steer |
Gap: lookup by durable session id. |
| subagent_abort_report.rs | 144 | UPSTREAM | tinyagents-tasks DetachedTaskRegistry abort guard |
Generic registry gap: a terminal event when the future is dropped. |
| wait_subagent.rs | 466 | REIMPLEMENT | OrchestrationTool Await / wait_detached |
Gaps: collected tombstone, awaiting-user envelope. |
| worker_thread.rs | 144 | RELOCATE | src/threads/ |
Worker-thread effects in the threads domain. |
agent/orchestration/workflow_runs/ (721 lines, 198 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 36 | RELOCATE | src/agent_runs/workflow_runs/ |
RPC re-export root. |
| engine.rs | 55 | DELETE | — | Docs plus module declarations only. |
| host.rs | 193 | KEEP | — | WorkflowExecutor port impl. |
| ops.rs | 107 | RELOCATE | src/agent_runs/workflow_runs/ |
Built-in catalog and ledger read adapters. |
| schemas.rs | 330 | RELOCATE | src/agent_runs/workflow_runs/ |
workflow_run_* RPC. |
agent/orchestration/workflow_runs/engine/ (496 lines, 62 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| cancel.rs | 108 | UPSTREAM | tinyagents-orchestration workflow run supervisor |
Cancel-token registry with generations. Fully generic. |
| lifecycle.rs | 388 | UPSTREAM | tinyagents-orchestration workflow run supervisor |
start/stop/resume around WorkflowEngine. Seams: spawn on ctx, root parent, origin. |
agent/subagent_host/ (2130 lines, 2787 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| autonomous.rs | 48 | KEEP | — | OpenHuman policy: lifts the iteration cap for skills_run. |
| lifecycle.rs | 1235 | UPSTREAM | tinyagents-orchestration file/driver SubagentPersistence |
About 580 lines of generic file-locked persistence. HostInFlight copies the driver's InFlight. Planner/executor impls stay. |
| lifecycle_checkpoint.rs | 15 | UPSTREAM | with persistence | Canonicalises the checkpoint dir. |
| lifecycle_outcome.rs | 86 | DELETE | — | Host-to-neutral conversion. Unneeded once host types are SubagentOutcome. |
| mod.rs | 78 | KEEP | — | Module root. |
| tool_prep.rs | 289 | REIMPLEMENT | subagent::{restrict_tools, is_delegation_tool} |
Gaps: ToolScope and skill_filter narrowing, dialect protocol block. |
| types.rs | 379 | REIMPLEMENT | subagent::{SubagentRequest, SubagentOutcome, SubagentError} |
Parallel taxonomy. Gaps: worker_thread_id, tier, model_override, usage fields. |
agent/subagent_host/ops/ (1674 lines, 1416 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| checkpoint.rs | 80 | UPSTREAM | tinyagents-harness summarization |
Summary at the iteration cap, with a deterministic fallback. |
| graph.rs | 71 | KEEP | — | Module root. |
| mod.rs | 80 | KEEP | — | Module root. |
| pause_checkpoint.rs | 104 | DELETE | — | write() only runs in tests. Move is_safe_task_id. |
| prompt.rs | 161 | REIMPLEMENT | subagent::subagent_framing |
Gaps: result-contract headings, artifact contract, spec dedup. |
| provider.rs | 108 | KEEP | — | Port from ModelSpec to the OpenHuman Provider. The Composio probe moves to src/integrations/. |
| runner.rs | 1045 | REIMPLEMENT | subagent::{ResultPolicy, ArtifactStore, run_agent_step} |
Offload and caps reimplement ResultPolicy. Gap: tier gate. |
| runner_result_cap.rs | 25 | DELETE | subagent::truncate_head_tail |
Duplicates the upstream cap. |
agent/subagent_host/ops/graph/ (1160 lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| dispatch.rs | 644 | KEEP | — | Composes the turn via TurnSpec::run. build_cap_digest moves with checkpoint.rs. |
| transcript.rs | 279 | KEEP | — | Chooses the transcript store per tenant. |
| worker_mirror.rs | 237 | RELOCATE | src/threads/ |
Mirrors child messages into threads::store. |
Notes for this section:
- Upstream code OpenHuman never calls:
steer_detached,record_detached_completion,spawn_status_watcher_with_completions,SpawnAdmission,ResultPolicy,OrchestrationTool,SubAgentTool/JobsTool/MessageTool,parallel::run_with_hooks. - Upstream gaps:
- a
SubAgentToolthat runs throughSubagentDriver(the current one wrapsSubAgent/AgentHarnessand skips the hostTurnSpec); - a multi-target delegation tool;
- a per-workspace completion router registry;
- durable reusable subagent sessions;
- a workflow run supervisor;
TeamService::start_memberwith an executor seam.
- a
- Proposed new domain:
src/agent_runs/for the orchestration product RPC.
Evaluation: tinyagents/, harness/, goals/, todos/, plan_review/, context/, library/, tools/, top-level files, and src/hooks/ (27,723 lines)
Tally: KEEP 11,825 · RELOCATE 5,959 · UPSTREAM 5,701 · DELETE 2,269 · REIMPLEMENT 1,969
agent/tinyagents/ (6608 lines, 11987 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 110 | KEEP | — | Root. Drop the message_convert re-export shims. |
| budget.rs | 68 | UPSTREAM | harness::limits / cost | ModelBudget (ledger + CallBudget over GatewayChargeModel) and install_depth are generic. MAX_SPAWN_DEPTH stays. |
| config.rs | 180 | KEEP | — | The only OH Config → harness SessionConfig/TurnConfig/ToolConfig mapping. |
| context_wiring.rs | 166 | KEEP | — | Installs upstream ContextLadder/FinalCallWrapUp with host summarizer and recall. |
| deadline_wind_down.rs | 48 | KEEP | — | Thin install_wind_down callback. |
| embeddings.rs | 79 | DELETE | — | ProviderEmbeddingModel has no callers; re-exported under allow(unused_imports). |
| hosted_error.rs | 51 | UPSTREAM | harness::runtime | No deps. From<HostedError> should carry timeout_bound. |
| journal.rs | 269 | UPSTREAM | harness::observability | Generic fan-out, redaction and status writes. Host keeps store opening. |
| live_harness.rs | 139 | KEEP | — | Voice live tool-gate assembly. |
| memory_summarizer.rs | 154 | KEEP | — | Summarizer decorator over the OH memory lifecycle. |
| model.rs | 195 | RELOCATE | inference/provider | ChatResponse/BilledUsage → ModelResponse is provider adaptation. |
| payload_summarizer.rs | 167 | KEEP | — | PayloadSummarizer impl (summarizer agent through TinyJuice). |
| policy_denial.rs | 229 | UPSTREAM | harness::middleware::policy_gate | No deps. Default DenialRenderer; host supplies the workaround copy. |
| reaper.rs | 50 | KEEP | — | Store opener around upstream reap_orphaned_runs. |
| reasoning.rs | 225 | RELOCATE | inference/reasoning | Per-thread effort registry and config precedence. |
| routes.rs | 267 | UPSTREAM | harness::retry + middleware | WORKLOAD_ROUTES router plus capability/fallback/usage middlewares. Generic. |
| run_mode.rs | 229 | RELOCATE | threads/run_mode | Thread RunModeHandle registry and RPC. |
| steering_forwarder.rs | 131 | KEEP | — | QueuedMessage/RunQueueFeed/SteeringRegistrar port impls with bus events. |
| stop_hooks.rs | 49 | UPSTREAM | tinyagents-hooks (stop) | Installs StopHookMiddleware plus HaltSummarySlot. Needs .with_halt_summary. |
| todos.rs | 25 | DELETE | — | Third resolver for the same todo KV store. |
| tool_registration.rs | 283 | KEEP | — | Typed-dispatch selection over ToolSetBuilder. |
| turn_exec.rs | 696 | KEEP | — | Drives TurnDriver/AgentInvocation; turn entry. |
| turn_exec_hosted.rs | 36 | REIMPLEMENT | harness::host::StaticContextComposer::empty() |
PrecomposedRootContext duplicates the upstream empty composer. |
| turn_middleware.rs | 600 | KEEP | — | Host middleware stack order. |
| turn_model_resolver.rs | 90 | UPSTREAM | harness::host::model_resolver | No deps. Generic prebuilt-routes resolver. |
| turn_models.rs | 689 | RELOCATE | inference/turn_models | Model construction from factory, egress, window. |
| turn_outcome.rs | 133 | KEEP | — | Host outcome DTO. |
| turn_plan.rs | 188 | KEEP | — | TurnPlanner port impl. |
| turn_policy.rs | 171 | KEEP | — | OPENHUMAN_* env overrides over turn_policy::run_policy. |
| turn_run_error.rs | 90 | KEEP | — | classify_run_failure → OH typed errors. |
| turn_run_finalize.rs | 299 | KEEP | — | Host outcome over classify_turn_end. |
| use_skill_dispatch.rs | 366 | UPSTREAM | harness::tool::packs | Live-parent redispatch goes beside UseSkillTool. Needs a selector seam. |
| verify_before_finish.rs | 136 | KEEP | — | OH policy over upstream VerifyBeforeFinishMiddleware. |
agent/tinyagents/host/ (4722 lines, 3909 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| budget_gate.rs | 413 | KEEP | — | BudgetGate over scheduler gate, cost budgets, TinyJuice. |
| bundle.rs | 230 | KEEP | — | Assembles HostCapabilities. Shrinks once the dead adapters go. |
| context_composer.rs | 249 | DELETE | — | Dead on hosted root turns: turn_exec.rs:603 replaces it with PrecomposedRootContext. Check subagent/live paths before deleting. |
| definition_registry.rs | 491 | KEEP | — | DefinitionRegistry port impl. |
| delegation.rs | 88 | DELETE | — | Old-import-path wrappers over tinyagents_graph::delegation. |
| learning_sink.rs | 137 | DELETE | — | turn_exec.rs:609 sets learning = None. PostTurnHook duplicates LearningSink (see tinyagents-hooks). |
| model_resolver.rs | 367 | DELETE | — | Always replaced by TurnModelResolver on hosted turns. Check the other paths. |
| mod.rs | 60 | KEEP | — | Root. |
| operation_context.rs | 166 | KEEP | — | Typed state-view readers for tools. |
| progress_sink.rs | 593 | DELETE | NoopProgressSink |
Writes to a channel nothing reads. OpenhumanEventBridge is the real producer. |
| run_context.rs | 749 | KEEP | — | OpenHumanRunContext host carrier. |
| security_gate.rs | 688 | KEEP | — | SecurityGate impl. Security stays in OH. |
| security_gate_approval.rs | 63 | KEEP | — | Approval → gate decisions. |
| security_gate_impl.rs | 109 | KEEP | — | Trait impl over prompt_injection. |
| security_gate_shell_analysis.rs | 31 | KEEP | — | Shell-fact plumbing. |
| steering.rs | 42 | KEEP | — | OH SteeringPolicy allowlist. |
| tool_outcome_classifier.rs | 246 | UPSTREAM | harness::host::tool_outcome_classifier | Only uses tinytools::status and the harness. Ship as a stock classifier. |
agent/tinyagents/middleware/ (3329 lines incl. middleware.rs)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| ../middleware.rs | 63 | KEEP | — | Root. |
| approval.rs | 182 | KEEP | — | ApprovalResolver over security::approval::ApprovalGate. |
| credential_scrub.rs | 70 | KEEP | — | Upstream scrubber plus the browser-token exemption. |
| embedder_hooks.rs | 258 | UPSTREAM | tinyagents-hooks (ToolHook middleware) | Generic. Host supplies the identity extractor. |
| failure_policy.rs | 261 | KEEP | — | OH tool-vocabulary recovery tables fed to the upstream ladder. |
| fetched_site.rs | 66 | UPSTREAM | tinytools::status | web_fetch status shape belongs in the tinytools classifier. |
| memory_pack.rs | 37 | KEEP | — | MemoryPackSource impl. |
| packed_tool_route.rs | 48 | KEEP | — | Router policy. |
| repeated_failure.rs | 655 | REIMPLEMENT | harness::no_progress::{RecoverableFailureLadder, classified_step} |
Driver loop goes upstream. Gaps: failure_scope hook, terminal-inference fast-halt, halt copy, memory-tool exemption. |
| tool_outcome_capture.rs | 190 | UPSTREAM | harness::turn_outcome | Writes ToolCallOutcome into ToolOutcomeSink. Generic. |
| tool_output.rs | 620 | UPSTREAM | harness::middleware::library::output_ladder | Shell goes upstream. TinyJuiceProcessor and the exempt lists stay as host OutputProcessor/OutputCapPolicy. |
| tool_policy.rs | 410 | REIMPLEMENT | ToolPolicyGateMiddleware + DenialRenderer |
Gaps: ToolPolicySession ceiling, session-scoped use_skill listing. |
| turn_context.rs | 469 | UPSTREAM | harness::middleware (transcript snapshot) | TranscriptSnapshot, render_unanswered_steps. Duplicates DEFAULT_TOOL_RESULT_BUDGET_BYTES. |
agent/tinyagents/observability/ (1347 lines incl. observability.rs)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| ../observability.rs | 33 | KEEP | — | Root. |
| bridge_types.rs | 77 | KEEP | — | Bridge state types. |
| event_bridge.rs | 467 | KEEP | — | The only AgentEvent → AgentProgress producer, plus cost-ledger writes. |
| event_projection.rs | 746 | KEEP | — | Host UI projection. Upstream stream::project targets StreamChunk. |
| tool_progress_projection.rs | 24 | KEEP | — | Helper. |
agent/tinyagents/replay/ (375 lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 12 | RELOCATE | agent_runs/ | RPC root. |
| ops.rs | 50 | RELOCATE | agent_runs/ | Store adapter over observability::replay. |
| schemas.rs | 313 | RELOCATE | agent_runs/ | agent_run_events/status/runs_active RPC. |
agent/tinyagents/discovery/ (293 lines, 263 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 244 | KEEP | — | Ranker slot (installed by openhuman-tinyhumans) plus config → ToolDiscoveryPolicy. |
| embedding_ranker.rs | 49 | KEEP | — | Host embedder → EmbeddingToolRanker. |
agent/harness/ (945 lines, 754 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| builtin_definitions.rs | 182 | DELETE | — | Wraps registry::agents::load_builtins. About 130 lines are test fixtures in non-test code. |
| fork_context.rs | 171 | KEEP | — | ParentExecutionContext host payload. Candidate to merge into OpenHumanRunContext. |
| graph.rs | 258 | KEEP | — | Channel/CLI turn entry over TurnSpec::run. |
| host_definition.rs | 299 | RELOCATE | agent_registry/ | AgentExt, global registry, OPENHUMAN_HOME/agents paths. Its validate_tier_hierarchy already delegates upstream. |
| mod.rs | 35 | KEEP | — | Root. |
agent/harness/artifact_offload/ (310 lines) and tool_result_artifacts/ (192 lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| artifact_offload/mod.rs | 231 | UPSTREAM | harness::artifacts | Materialize-to-fs and the target guard, through the PathPolicy seam. |
| artifact_offload/policy.rs | 79 | KEEP | — | Path/redactor policies with SecurityPolicy and scrub. |
| tool_result_artifacts/mod.rs | 192 | KEEP | — | Host redactor, tool vocabulary, store binding. |
agent/goals/ (476 lines, 207 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 24 | KEEP | — | Root plus the serde helper. |
| runtime.rs | 272 | UPSTREAM | tinyagents-graph::goals + tinyagents-hooks | GoalBudgetStopHook over GoalBudgetGuard. The event threshold should reuse GoalUpdateHook. |
| store.rs | 131 | DELETE | — | Pass-throughs that only stringify errors. |
| tools.rs | 49 | KEEP | — | Binds the store and ThreadGoalUpdated onto upstream GoalTool. |
agent/todos/ (90 lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 12 | DELETE | — | Shell. |
| ops.rs | 78 | DELETE | — | Scope → key over tinyagents_graph::todos::store. Callers pass the thread id. |
agent/plan_review/ (621 lines, 213 test lines): RELOCATE the whole folder to src/plan_review/
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| gate.rs | 241 | RELOCATE | plan_review/ | Product park gate with DomainEvent and a UI card. |
| mod.rs | 22 | RELOCATE | plan_review/ | Root. |
| schemas.rs | 120 | RELOCATE | plan_review/ | plan_review_decide RPC. |
| tool.rs | 202 | RELOCATE | plan_review/ | Product tool. |
| types.rs | 36 | RELOCATE | plan_review/ | Types. |
agent/context/ (572 lines, 306 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| channels_prompt.rs | 281 | RELOCATE | channels/ | channels/system_prompt.rs already re-exports it. |
| manager.rs | 205 | DELETE | — | Legacy ContextManager: config getters plus a held builder. |
| mod.rs | 37 | DELETE | — | CLEARED_PLACEHOLDER duplicates upstream DEFAULT_CLEARED_PLACEHOLDER; budget constant duplicated. |
| stats.rs | 49 | REIMPLEMENT | harness::context::stats / ResponseUsage |
Gap: context-window value from BilledUsage. |
agent/library/ (166 lines, 77 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 7 | RELOCATE | agent_registry/ | Root. |
| ops.rs | 124 | RELOCATE | agent_registry/ | agent.list_definitions UI projection. |
| types.rs | 35 | RELOCATE | agent_registry/ | Display DTOs. AgentDefinitionSource mirrors tinyagents_definition::DefinitionSource. |
agent/tools/ + tools.rs (1279 lines, 868 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| tools.rs | 40 | KEEP | — | Root. Re-exports upstream AskClarificationTool. |
| delegate.rs | 323 | RELOCATE | tools/ | Product DelegateTool. A third delegation path; collapse it with spawn_subagent/delegate_graph. |
| plan_exit.rs | 135 | UPSTREAM | harness::middleware (plan mode) | Upstream plan mode names plan_exit but ships no tool. Host supplies the RunModeHandle lookup. |
| run_workflow.rs | 525 | RELOCATE | skills/ | run_workflow/await_workflow product tools. |
| todo.rs | 256 | KEEP | — | Thread/legacy key mapping plus ThreadTodosChanged around upstream TodoTool. |
agent/ (top-level files) (5273 lines, 4228 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 106 | KEEP | — | Domain root. |
| bus.rs | 477 | KEEP | — | agent.run_turn native bus port. |
| context_breakdown.rs | 242 | RELOCATE | agent_runs/ (RPC) | agent.context_breakdown RPC over debug prompt_size. |
| cost.rs | 75 | UPSTREAM | harness::cost | Pricing over registry::pricing plus the :free rule. BilledUsage→CallUsage goes to inference. |
| hooks.rs | 383 | UPSTREAM | tinyagents-hooks | ToolHook, PostTurnHook, ToolHookContext/Decision, fire_hooks. The global registries stay in OH. |
| hooks_scope.rs | 67 | UPSTREAM | tinyagents-hooks::HookScope | Plain data. |
| host_agents.rs | 179 | KEEP | — | HostAgentResolver embedder port for cron/workflow. |
| host_overrides.rs | 143 | KEEP | — | Agent-owned injection points. |
| host_runtime.rs | 209 | RELOCATE | modules/tinybox (sandbox) | Native/Docker shell RuntimeAdapter. |
| message_convert.rs | 478 | UPSTREAM | tinyagents-runtime::transcript | TranscriptMessage ↔ Message/TranscriptEntry. ChatResponse helpers go to inference. |
| messages.rs | 110 | UPSTREAM | tinyagents-session::transcript (legacy) | Legacy {role,content} row serde. |
| multimodal.rs | 725 | REIMPLEMENT | harness::multimodal::{markers, resolve, payload, BlobAttachmentStash} |
Duplicates marker helpers. Gaps: max_files:0 clamp, PDF extractor, attachment-dir statics. |
| progress.rs | 462 | RELOCATE | progress/ (UI contract domain) | AgentProgress is the web_chat/channels UI contract. |
| progress_sink.rs | 28 | DELETE | — | One alias. Its name collides with harness::host::ProgressSink. |
| progress_tracing.rs | 94 | REIMPLEMENT | harness::observability::{trace_export, langfuse} |
See the progress_tracing section. |
| queued_turn.rs | 82 | KEEP | — | Host QueuedMessage payload. |
| registration.rs | 73 | KEEP | — | Dialogue tool registration. |
| schemas.rs | 745 | RELOCATE | agent_runs/ (RPC) | Product RPC controllers. |
| stop_hooks.rs | 76 | UPSTREAM | tinyagents-hooks (stop) | Generic BudgetStopHook. tool_call_limit goes to turn_policy. |
| turn_env.rs | 88 | KEEP | — | HostTurnEnv per-turn carrier. |
| turn_origin.rs | 373 | RELOCATE | security/turn_origin | Trust labels read by ApprovalGate/ToolPolicyEngine. |
| turn_projection.rs | 58 | DELETE | — | Curries stop_fallback_class onto TurnStop. Fold into stop_summary. |
src/hooks/ (outside agent/) (1125 lines, 222 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 39 | KEEP | — | Domain root. |
| bridge.rs | 373 | UPSTREAM | tinyagents-hooks (command ↔ ToolHook adapter) | Derived Cursor events and decision mapping. Host supplies the tool-family names and MCP prefix. |
| host.rs | 74 | KEEP | — | Product name, home and env for HookEnvironment. |
| ops.rs | 263 | UPSTREAM | tinyagents-hooks (lifecycle entry points) | session_started, prompt_submitted, pre_compact, subagent_* are engine API. init stays. |
| prompt_eval.rs | 51 | KEEP | — | Prompt-hook eval through OH inference. |
| schemas.rs | 205 | KEEP | — | Product RPC. |
| shell.rs | 120 | KEEP | — | TinyBox shell seam. |
Notes for this section:
- Dead adapters on root turns. About 1.35k lines in
tinyagents/host/are dead on hosted root turns.turn_exec.rs:603-609replaces the context composer and setslearning = None.OpenHumanModelResolveris replaced byTurnModelResolver. The progress sink's channel is never read. Confirm subagent and live paths before deleting. - Duplicated definitions:
AgentProgresshas two producers; onlyobservability/event_bridge.rsreaches the UI.DEFAULT_TOOL_RESULT_BUDGET_BYTESis defined twice.- The todo store resolver exists three times:
tinyagents/todos.rs,todos/ops.rsandgoals/store.rs.
Evaluation: session_host/, session_*/, progress_tracing/, registry/, prompts/, artifacts/, attachments/, triage/, debug/ (29,433 lines)
Tally: KEEP 6,242 · UPSTREAM 4,574 · REIMPLEMENT 5,149 · DELETE 1,050 · RELOCATE 12,418
agent/session_host/ (11699 lines, 7819 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| announcement_notes.rs | 43 | RELOCATE | integrations (copy); delivered via harness ephemeral_instructions |
Product copy for connected-integration notes. |
| artifact_wiring.rs | 120 | RELOCATE | artifacts (tool_results) | Store selection and cache-dir pruning are storage policy. |
| builder/builder_build.rs | 504 | KEEP | — | Composition root assembling OpenHumanSessionHost. |
| builder/factory.rs | 965 | KEEP | — | from_config composition: config to provider, tools, prompt, definition. Oversized; split. |
| builder/factory_workflows.rs | 18 | KEEP | — | Skills/flows catalogue to session. |
| builder/host_only.rs | 201 | KEEP | — | ToolCallPolicy port impl. |
| builder/host_tools.rs | 445 | KEEP | — | Embedder HostTools seam used by openhuman-embed. |
| builder/iteration_cap.rs | 58 | KEEP | — | OH cap precedence. |
| builder/mod.rs | 297 | REIMPLEMENT | tinyagents_runtime::tool_registration::{plan_registration, reject_synthesized_collisions} |
Name dedup and collision drop duplicate upstream admission. |
| builder/profile_factory.rs | 36 | KEEP | — | Profile to host-only session. |
| builder/setters.rs | 399 | KEEP | — | Fluent host-builder setters. |
| codec.rs | 353 | UPSTREAM | tinyagents-runtime::transcript (default TranscriptCodec::reconcile) |
Matching messages to prior rows is generic. Host keeps the metadata/usage callbacks. |
| driver/grounded_close.rs | 418 | UPSTREAM | tinyagents-harness turn_run_finalize / new close |
Tools-disabled grounded close and required-output repair. Seam: ChatModel + ToolDialect. |
| driver.rs | 748 | REIMPLEMENT | tinyagents_runtime::turn_driver::{TurnDriver, TurnPlanner} |
Wraps a SessionDriver around TurnSpec (already a TurnDriver), so two driver layers per turn. Gaps: post-loop close hook, error snapshot, orphaned-head repair. |
| factory.rs | 37 | DELETE | tinyagents_runtime::SessionBuilder |
Test-only references. |
| hooks.rs | 131 | UPSTREAM | tinyagents-hooks (FnSessionHooks<C>) |
Generic closure adapter for SessionHooks. |
| live_tools.rs | 49 | KEEP | — | Voice live harness tool surface. |
| mod.rs | 88 | KEEP | — | Index. |
| prefix_snapshot.rs | 28 | DELETE | tinyagents_runtime::PrefixSnapshot |
One-function adapter. |
| prelude_integrations.rs | 607 | RELOCATE | integrations (session_refresh) | Composio/MCP hydration and connect/revoke tracking are integration logic. |
| recorded_tools.rs | 164 | RELOCATE | integrations/composio | Rebuilds ComposioActionTool from recorded specs. |
| runtime/accessors.rs | 657 | KEEP | — | Host getters/setters. Trim the _for_test accessors. |
| runtime.rs | 23 | KEEP | — | Index. |
| runtime/run_loop.rs | 177 | KEEP | — | Product entry: injection guard, BUS events, busy guard. |
| runtime_session_attachment_input.rs | 19 | DELETE | attachments::stage_turn |
One-call forwarder. |
| runtime_session/memory_ingest.rs | 319 | RELOCATE | memory (lifecycle::session_hooks) | Memory pre/post-turn logic. |
| runtime_session/parent_snapshot.rs | 57 | KEEP | — | Parent snapshot for subagents. |
| runtime_session/permanent.rs | 62 | UPSTREAM | tinyagents-runtime::managed_tools | Visible/deferred/permanent set algebra. |
| runtime_session/post_commit.rs | 263 | KEEP | — | after_commit effect ordering. |
| runtime_session_progress.rs | 107 | KEEP | — | CommitReceipt to AgentProgress::TurnCompleted. |
| runtime_session.rs | 1065 | KEEP | — | Core Session composition. Extract its integration parts. |
| runtime_session/tool_rules.rs | 104 | KEEP | — | Installs ToolRulePolicy. |
| runtime_session_tool_surface.rs | 238 | REIMPLEMENT | turn_driver::ToolSetBuilder, tool_registration |
Per-turn surface reconcile is generic. Gap: refresh of the synthesized set and visibility diff upstream. |
| runtime_session/transcript.rs | 67 | KEEP | — | Transcript locator wiring. |
| runtime_session_turn.rs | 154 | KEEP | — | turn_with_origin / turn_with_approval. |
| runtime_session_usage.rs | 68 | UPSTREAM | tinyagents-harness::cost (sub-agent usage rollup) | Child usage/cost summing is generic. |
| runtime/turn_helpers.rs | 89 | REIMPLEMENT | CommitReceipt rows, harness::agent_error::AgentError |
Duplicates the commit delta and error-kind mapping. |
| runtime/turn_results.rs | 49 | KEEP | — | Last-turn usage and cap flag. |
| session_api.rs | 57 | DELETE | Session::resume |
Test-only callers. |
| stop_summary.rs | 297 | REIMPLEMENT | harness::turn_stop::TurnStop (typed failure class) |
String-matches harness note templates. The copy table moves to inference::failure_copy. |
| tool_progress.rs | 269 | DELETE | — | Compiled only under #[cfg(test)]. Legacy. |
| turn_backstop.rs | 71 | RELOCATE | web_chat (turn_guards) | Web-chat-only env override. |
| turn_checkpoint.rs | 594 | UPSTREAM | tinyagents-harness turn_run_finalize / close |
Checkpoint, close-repair prompts and CloseVerdict parser are host-free. |
| turn/context.rs | 103 | KEEP | — | build_system_prompt (debug and channels). |
| turn/graph.rs | 174 | REIMPLEMENT | turn_driver::TurnControls |
max_iterations / pause_at_cap / early_exit_tools / defer_turn_completed are exactly TurnControls. |
| turn/mod.rs | 8 | DELETE | — | Index for an emptied folder. |
| turn/tools.rs | 246 | DELETE | prelude refresh | Duplicates the turn-boundary delegation refresh. |
| types.rs | 653 | KEEP | — | OH host/builder structs. Shrinks as fields move upstream. |
agent/session_store/ (1184 lines, 636 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| ledger_sync.rs | 168 | DELETE | with_ledger / RunLedgerStore |
Sync wrappers with one non-test caller (web_chat/progress_bridge.rs). |
| mod.rs | 322 | RELOCATE | storage (sessions) | Process-wide SessionStoreProvider install. Storage implementation. |
| rebound.rs | 195 | UPSTREAM | tinyagents_session::port (rebindable DriverSessionStores) |
Generic swap-in-place provider. |
| splice_fixture.rs | 92 | REIMPLEMENT | tinyagents_session::testkit::in_memory_transcript |
Test fixture. |
| workspace.rs | 407 | RELOCATE | storage (sessions) | Workspace fallback provider, tenant scope. |
agent/session_db/ (249 lines, 174 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 29 | RELOCATE | sessions (run_ledger RPC) | Index. |
| schemas.rs | 220 | RELOCATE | sessions (run_ledger RPC) | Product RPC over run_ledger. |
agent/session_import/ (228 lines, 110 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| live.rs | 43 | RELOCATE | storage (sessions) | KV handle for RunContext.stores. |
| mod.rs | 14 | RELOCATE | storage/import | Index. |
| schemas.rs | 171 | RELOCATE | storage/import | session_import_run RPC over tinyagents_session::legacy. |
agent/progress_tracing/ (3099 lines + progress_tracing.rs 94; 4053 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| ../progress_tracing.rs | 94 | RELOCATE | core/observability (agent_tracing) | Index. |
| collector/events.rs | 577 | UPSTREAM | harness observability::trace_export collector |
Folds events into a span tree. Seam: fold AgentEvent, not AgentProgress. |
| collector/finish.rs | 221 | UPSTREAM | trace_export collector | Span seal and outcome. |
| collector/generation.rs | 127 | UPSTREAM | trace_export + registry::pricing | Usage normalisation, cost provenance, TTFT. |
| collector/model_call.rs | 371 | UPSTREAM | trace_export collector | Generation spans. |
| collector/mod.rs | 14 | UPSTREAM | trace_export collector | Index. |
| collector/span_lifecycle.rs | 155 | UPSTREAM | trace_export collector | Span bootstrap and parent resolution. |
| collector/state.rs | 306 | UPSTREAM | trace_export collector | State over upstream TraceSpan/TraceContext. No OH deps. |
| export.rs | 207 | RELOCATE | core/observability | Config-driven sink selection. |
| journal_projection.rs | 726 | REIMPLEMENT | trace_export::journal_export, observability::replay |
Projects AgentEvent to AgentProgress only to feed the collector. Goes away with it. |
| journal_replay.rs | 100 | DELETE | harness::terminal::TerminalOutcome |
Projection helpers. |
| langfuse.rs | 46 | DELETE | — | Shim; test-only imports. |
| langfuse/environment.rs | 151 | RELOCATE | backend (telemetry) | TinyHumans backend URL and push gating. |
| langfuse/journal_export.rs | 22 | RELOCATE | backend (telemetry) | Credential readiness gate. |
| otlp.rs | 76 | REIMPLEMENT | harness::observability::langfuse::LangfuseClient::proxy + send_otlp |
Hand-rolled proxy POST. Gaps: transport client/header injection, partialSuccess check. |
agent/registry/ (2556 lines, 3307 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 24 | RELOCATE | agent_registry | Product registry index. |
| defaults.rs | 170 | RELOCATE | agent_registry | Entry/definition conversion. |
| ops.rs | 290 | RELOCATE | agent_registry | Config-backed custom-agent CRUD. |
| rpc.rs | 215 | RELOCATE | agent_registry | RPC payloads and handlers. |
| schemas.rs | 344 | RELOCATE | agent_registry | agent_registry_* controllers. |
| types.rs | 177 | RELOCATE | agent_registry | Entry, patch and policy types. |
| agents/mod.rs | 44 | RELOCATE | agent_registry (builtins) | Builtin index. |
| agents/loader.rs | 291 | REIMPLEMENT | tinyagents_definition::{DefinitionSet::validate_tier_hierarchy, load_file, InMemoryDefinitionRegistry} |
Reimplements tier validation (a copy also sits in harness/host_definition.rs:126) and TOML parsing. Gaps: include_str! sources, PromptSource::Dynamic stamping. |
| agents/*/mod.rs (11 files) | 11 | DELETE | — | pub mod prompt; boilerplate. Fold into the loader table. |
| agents/{critic,image_agent,morning_briefing,orchestrator,planner,presentation_agent,summarizer,task_manager_agent,video_agent,vision_agent}/prompt.rs | 927 | RELOCATE | agent_registry (builtins) | Product prompt copy; orchestrator alone is 613. |
| agents/{trigger_reactor,trigger_triage}/prompt.rs | 62 | RELOCATE | triage | Triage-domain prompts. |
agent/prompts/ (2446 lines, 1703 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| mod.rs | 30 | DELETE | — | Glob re-export shim. |
| agents_md.rs | 235 | UPSTREAM | tinyagents-harness::context (agents_md loader) | Generic AGENTS.md layering with a no-follow open. Upstream has the agents_md_enabled flag but no loader. |
| builder.rs | 356 | REIMPLEMENT | harness::prompt::{PromptBuilder, PromptSection, assemble_sections_with_budget} |
Section assembly and tiered segments duplicate upstream. Gap: stable/context/volatile cache tiers. |
| connected_identities.rs | 62 | RELOCATE | integrations (identities) | Product data. |
| render_helpers.rs | 30 | DELETE | — | Re-export index. |
| render_helpers/section_renderers.rs | 209 | RELOCATE | prompts (product copy domain) | Safety/identity/datetime copy. |
| render_helpers/subagent.rs | 257 | REIMPLEMENT | harness::prompt + tinytools-agent dialect prompt_instructions |
Format-to-dialect prompt dispatch belongs with the dialects. |
| render_helpers/workspace_files.rs | 262 | RELOCATE | prompts (persona/workspace files) | SOUL.md/USER.md seeding. |
| sections.rs | 539 | RELOCATE | prompts (product copy domain) | Concrete OH sections. |
| types.rs | 466 | REIMPLEMENT | harness::prompt::PromptSection / segments |
Duplicates PromptSection, PromptTier and the tier markers. ConnectedIntegration types move to integrations. |
agent/artifacts/ (2552 lines, 2455 test lines): RELOCATE the whole folder to src/artifacts/
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| files.rs | 328 | RELOCATE | artifacts | Files-folder placement and escape guard. |
| migrate.rs | 257 | RELOCATE | artifacts | Legacy boot migration. |
| mod.rs | 21 | RELOCATE | artifacts | Index. |
| ops.rs | 278 | RELOCATE | artifacts | list/get/delete/regenerate ops. |
| schemas.rs | 377 | RELOCATE | artifacts | RPC controllers. |
| store_documents.rs | 348 | RELOCATE | artifacts | Document-port records. |
| store.rs | 598 | RELOCATE | artifacts | Lifecycle store. Not the harness tool-result store. |
| tools.rs | 212 | RELOCATE | artifacts (tools) | artifact_list/get/delete tool impls. |
| types.rs | 133 | RELOCATE | artifacts | Data model. |
agent/attachments/ (2281 lines, 2326 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| host.rs | 132 | RELOCATE | attachments | Host byte-attachment staging. |
| legacy.rs | 181 | RELOCATE | attachments | Legacy sidecar migration. Delete when the window closes. |
| mod.rs | 618 | RELOCATE | attachments | Durable uploads and SecurityPolicy paths. |
| provider.rs | 471 | UPSTREAM | harness::multimodal (request-preparing ChatModel wrapper) | Generic media resolution into a disposable request. Seam: host source resolver plus access scope. |
| provider_cache.rs | 180 | RELOCATE | attachments | Text-derivative cache. |
| provider_fallback.rs | 276 | UPSTREAM | harness::multimodal | Text fallback for non-vision models. |
| provider_open.rs | 153 | RELOCATE | security (fs secure_open) | No-follow descriptor-bound open is a security primitive. |
| provider_source.rs | 270 | RELOCATE | attachments | Host/legacy source resolution. |
agent/triage/ (2225 lines, 1962 test lines)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| decision.rs | 265 | REIMPLEMENT | harness::structured::repair::parse_lenient |
Hand-rolled fence/brace extraction. Keep only the TriageDecision schema. Gap: a "last object" option. |
| envelope.rs | 180 | RELOCATE | triage | Trigger envelope. |
| escalation.rs | 319 | RELOCATE | triage | Reactor/orchestrator dispatch. |
| evaluator.rs | 63 | RELOCATE | triage | Index. |
| evaluator/arm.rs | 327 | REIMPLEMENT | harness::retry::FailoverReason::classify |
String-matched error classes. |
| evaluator/chain.rs | 450 | REIMPLEMENT | harness::retry::failover::decide |
Duplicates failover. The outage state and LlmPermit stay host-side or go upstream as a persistent breaker. |
| evaluator/outcome.rs | 68 | RELOCATE | triage | Result types. |
| evaluator/prompt.rs | 90 | RELOCATE | triage | Classifier message. |
| events.rs | 110 | RELOCATE | triage | Trigger* events. |
| mod.rs | 47 | RELOCATE | triage | Index. |
| origin.rs | 74 | RELOCATE | triage | Trust-origin labels. |
| routing.rs | 232 | RELOCATE | triage | Provider resolution. Its docs say the local path was removed, yet chain.rs still calls build_local_provider_with_config. |
agent/debug/ (820 lines, 328 test lines): RELOCATE the whole folder to core/agent_cli (debug)
| File | Lines | Verdict | Target | Reason |
|---|---|---|---|---|
| dump_writer.rs | 127 | RELOCATE | core/agent_cli | Its only caller is core/agent_cli.rs. |
| mod.rs | 230 | RELOCATE | core/agent_cli | CLI dump entry points. |
| prompt_size.rs | 282 | RELOCATE | core/agent_cli | agent prompt-size report. |
| wire.rs | 181 | RELOCATE | core/agent_cli | Wire-dump renderer. |
Notes for this section:
driver.rswrapsTurnSpec::run_hosted, which already builds an upstreamTurnDriver(agent/tinyagents/turn_exec.rs:234). Collapse them to one driver layer.- Upstream
trace_export/mod.rssays hosts own the progress-event collector. Moving the collector up reverses that stated boundary, so it needs an explicit decision. The rule in this issue (harness owns observability folding) says move it.
Activity
tinysweeper commentedon Oct 16, 2026
Large internal refactoring plan: move generic harness code from openhuman-core's agent/ into tinyagents (including a new tinyagents-hooks crate), relocate product code to new/existing OpenHuman domains, and shrink agent/ from ~79k to ~22k non-test lines. It is a big mechanical reorg task with a handful of small correctness bugs noted along the way (delegate_graph error strings, completion_target awaiting_input, triage/routing docs vs chain.rs, test-only code in prod builds). No functional breakage reported, so p3. It resembles the shrink/consolidation trackers #7390 and #7332 in area, but neither is clearly the same underlying issue, so no duplicate is claimed.
Labelled
priority: p3.45 remaining items
senamakel commentedon Oct 18, 2026
Test-ownership audit (#8089): these unit tests should move upstream together with the code rows they cover, in the same tinyagents PR, and the host PR deletes them:
agent/progress_tracing/progress_tracing_*_tests.rsandcollector/generation(~2.7k, pure event→span).journal_projection*(1.1k) becomes a duplicate after adoption.agent/tinyagents/middleware_tool_output*_tests.rsandmiddleware/tool_output_tests.rs(~0.9k of 1.3k; upstreamoutput_ladderhas 5 tests). Of therepeated_failure/classified-failure family (3.3k), ~1.3k becomes a duplicate ofharness::no_progress. Alsomiddleware/turn_context,tool_outcome_capture,policy_denial.orchestration/background_delivery*,delivery_drain(1.2k).background_completions*(0.8k) becomes a duplicate.session_host/turn_checkpoint_tests(511),driver/grounded_close_tests(343), already ontestkit.session_host/codec_adoption_tests,orphaned_head_resume_tests, and the stem half ofruntime_session/permanent_tests.subagent_host/lifecycle*_tests(464),orchestration/subagent_sessions/*(451).agent/tinyagents/routes_tests(248, already ScriptedModel),host/tool_outcome_classifier_tests(merge with upstream),hosted_error,stop_hooks.use_skill_dispatch_tests. tinyagents#482:attachments/provider*_tests(~1k of 1.5k). tinyagents#478:prompts/agents_md_tests.budget_stop_turn_tests,middleware_memory_and_hooks_tests,tests/in_process/agent_harness_public.rs(~740).host/{progress_sink,model_resolver,learning_sink,context_composer}andtinyagents/delegationtests (1.0k) with the code.