Skip to content

Resolve the three deferred TinyAgents §5 design decisions (recommend_tier, NotOwned, ToolScope/is_concurrency_safe) #4565

Closed

Description

@senamakel

Summary

The TinyAgents port audit (§5 of docs/tinyagents-port-plan.md) surfaced three code-quality items that are genuine design decisions, not mechanical fixes. The behavior-preserving parts were landed in #4542, but each carries a real "implement vs defer" choice that was intentionally left open. This issue tracks resolving them.

Problem / Context

Each item currently reads as dead/misleading code but changing it alters behavior, a public type, or a trust boundary — so it needs an explicit decision rather than a drive-by change. #4542 added clarifying comments/annotations in place; this issue is where the actual decisions land (some are gated on later port phases).

Scope

Three independent decisions:

  1. recommend_tier RAM scaling (src/openhuman/inference/presets.rs) — reads device RAM but always returns MVP_MAX_TIER; its test pins the non-scaling contract. Decide: implement RAM→tier scaling (and update recommend_tier_scales_with_ram), or formally keep the intentional MVP cap and drop the unused RAM read. fix(tinyagents-audit): execute §5 fix-in-place items — provider diagnostic, anchor coupling, dead-read clarifications #4542 documented it as an intentional cap.
  2. SteerError::NotOwned RPC-path ownership (src/openhuman/agent_orchestration/subagent_control.rs) — the arm is unreachable on the trusted RPC steer_control path (no ownership check there); the agent-tool running_subagents::steer path does enforce ownership. Enforcing it on the RPC path would change the JSON-RPC payload shape (forbidden during the port) → deferred to Phase 4 (graph::orchestration::SteeringRegistry ownership consolidation).
  3. ToolScope::AgentOnly vs All + is_concurrency_safe (src/openhuman/tools/traits.rs) — AgentOnly has three real constructors but no execution path gates on it (behaves like All); is_concurrency_safe maps to tinyagents ToolRuntime.idempotent, which the harness never reads for dispatch (serial tool loop). Reconcile with the crate tool model in Phase 2; adopting concurrency needs upstream parallel dispatch.

Acceptance criteria

  • recommend_tier — decision made and implemented (scale or formally cap + strip param)
  • NotOwned — RPC-path ownership resolved as part of Phase 4 SteeringRegistry, or explicitly documented as permanently trusted-RPC
  • ToolScope::AgentOnly / is_concurrency_safe — reconciled with the tinyagents tool model in Phase 2 (gate AgentOnly or collapse to All; wire concurrency only behind upstream parallel dispatch)
  • Diff coverage ≥ 80% — implementing PR(s) meet the changed-lines coverage gate

Related

Implementation Plan

Triage Assessment

Proposed Scope

  • In-scope:
    1. recommend_tier — either implement RAM-to-tier scaling or formally cap and remove the unused RAM read + diagnostic.
    2. SteerError::NotOwned — either wire ownership checks into the RPC steer_control path (changing JSON-RPC payload shape) or document the path as permanently trusted and add a compile-time unreachable guard.
    3. ToolScope::AgentOnly — either gate it behind execution-path filtering (collapsing to AgentOnly tools being invisible to non-agent contexts) or remove the variant and collapse all callers to All.
  • Explicit non-goals:
    • Not changing the TinyAgents crate model (that's Phase 2/4 upstream).
    • Not implementing parallel dispatch (prerequisite for is_concurrency_safe usage).
    • Not removing CliRpcOnly (separate concern).

Implementation Steps

  1. recommend_tier decision — Two sub-options, pick one:
    • Option A (scale): Replace line let tier = MVP_MAX_TIER with a match on ram_gb that returns ascending ModelTier values. Update recommend_tier_scales_with_ram test to assert different tiers for different RAM values. This requires the higher-tiers' models to be productised.
    • Option B (cap): Remove let ram_gb = device.total_ram_gb() read, remove the tracing::debug! line, and add a doc comment on recommend_tier stating the intentional cap. Update the test name from recommend_tier_scales_with_ram to recommend_tier_caps_at_mvp and pin all inputs to MVP_MAX_TIER.
  2. SteerError::NotOwned decision — Two sub-options:
    • Option A (Phase 4): Keep the unreachable arm. Add #[allow(unreachable_patterns)] with a doc comment referencing the Phase 4 issue. Optionally replace the string match with unreachable!("Phase 4 SteeringRegistry will handle ownership — see #4565").
    • Option B (trusted): Document steer_control as a permanently trusted-RPC path that bypasses ownership checks (like the core RPC's own internal dispatch). Remove the NotOwned match arm and let the compiler enforce no new variants are missed.
  3. ToolScope::AgentOnly / is_concurrency_safe decision — Two sub-options:
    • Option A (gate): In src/openhuman/agent/harness/tool_filter.rs, add a filter that excludes ToolScope::AgentOnly tools from non-agent contexts (e.g., CLI/RPC tool listing). This makes the variant meaningful. Update AgentOnly-scoped tools (e.g., agent_memory/tools.rs:90-91) to verify they are excluded from CLI/RPC.
    • Option B (collapse): Remove AgentOnly from the enum, rename all references to All. Add a doc comment noting that the distinction was not used and is deferred to a future tool-scoping model.
  4. is_concurrency_safe — Add a #[expect(dead_code)] or gate behind a concurrent-tools Cargo feature. Wire into the harness dispatch only when upstream parallel dispatch exists. Alternatively, remove the method from the Tool trait and re-add it when parallel dispatch lands.

Verification

  • cargo test --lib openhuman::inference::presets::tests — updated recommend_tier tests.
  • cargo test --lib openhuman::agent_orchestration::subagent_control::tests — control path tests.
  • cargo test --lib openhuman::tools::traits::tests — ToolScope equality and filter tests.
  • cargo check --no-default-features --features tokenjuice-treesitter — verify no feature-forwarding drift.
  • Full suite: pnpm test:rust.

Risks and Open Questions

  • Option A for recommend_tier (RAM scaling) needs the higher tiers to have productised models. If they aren't ready, Option B is the only viable path.
  • Phase 4 SteeringRegistry is not yet scheduled. If deferred indefinitely, Option B (trusted-RPC) for NotOwned is cleaner.
  • Collapsing AgentOnly to All is safe because no execution path currently reads it, but it removes forward-looking API surface that future tool-modeling may want.

Acceptance Criteria

  • All three decisions resolved with code changes, not just documentation.
  • Tests updated to pin the new contracts.
  • No unused parameters, dead match arms, or misleading enum variants remain.
  • Diff coverage >= 80%.

Activity

  1. senamakel commented on Jul 23, 2026

    @senamakel
    MemberAuthor

    Triage: ESCALATE — well-scoped, overlooked.

    Three concrete TinyAgents §5 design decisions, each independently shippable:

    1. recommend_tier RAM scaling — formal cap or implement scaling
    2. SteerError::NotOwned on RPC path — enforce in Phase 4 or document as trusted-RPC
    3. ToolScope::AgentOnly / is_concurrency_safe — reconcile in Phase 2

    Each names the exact file, symbol, and relevant test. Zero comments since creation (2026-07-05). Needs labels (rust-core) and an assignee. Each item is a small, self-contained PR.

  2. added
    rust-core
    on Jul 23, 2026
  3. YellowSnnowmann commented on Sep 11, 2026

    @YellowSnnowmann
    Member

    Re-verified on main (6be58a9) — all three still open. Two have moved file, and item 3 has moved out of this repository entirely.

    Seconding the escalate triage; adding the current locations, since every path in the issue body has drifted since 2026-07-05.


    1. recommend_tier RAM scaling — unchanged, still exactly as described. src/openhuman/inference/presets.rs:229-239:

    pub fn recommend_tier(device: &DeviceProfile) -> ModelTier {
        // NOTE: the MVP intentionally caps every device at `MVP_MAX_TIER`
        // regardless of installed RAM (the `recommend_tier_scales_with_ram` test
        // pins this non-scaling contract). `ram_gb` is read only for the
        // diagnostic log below; RAM->tier scaling is deferred until the higher
        // tiers are productised.
        let ram_gb = device.total_ram_gb();
        let tier = MVP_MAX_TIER;
        tracing::debug!(ram_gb, ?tier, "[local_ai] recommended model tier");
        tier
    }

    The #4542 comment is in place and ram_gb is still log-only. Decision outstanding. This is the one item still entirely within this repo and genuinely a small PR either way.


    2. SteerError::NotOwned — still present; file path in the issue is stale. The issue points at src/openhuman/agent_orchestration/subagent_control.rs, which no longer exists. It is now src/openhuman/agent/orchestration/running_subagents_part_02.rs:207-214:

    pub enum SteerError {
        Unknown,
        /// The caller's `parent_session` does not own this sub-agent.
        NotOwned,
        AlreadyDone,
    }

    Note there is also a sibling WaitError::NotOwned (running_subagents_part_01.rs:294, running_subagents_part_02.rs:124/136/162/188) — worth checking whether the Phase 4 ownership consolidation should cover both, since they are the same trust question on two verbs.


    3. ToolScope::AgentOnly / is_concurrency_safe — the decision is no longer this repo's to make alone.

    ToolScope is no longer in src/openhuman/tools/traits.rs. It now lives in the vendored tinytools crate: vendor/tinyagents/vendor/tinytools/crates/tinytools/src/classification/types.rs:7. So "gate AgentOnly or collapse to All" is now a tinytools change plus a submodule bump, not a local edit — which materially changes the effort and the sequencing of this acceptance criterion.

    The good news is the ambiguity the issue flagged has been written down at the definition site, so the state is no longer implicit (types.rs:11-17):

    /// Intended to mark tools available only in the autonomous agent loop.
    ///
    /// Not yet enforced by any known host: no execution path filters on this
    /// variant, so it currently behaves like [`Self::All`]. It is kept because
    /// tools already annotate themselves with it, and losing those annotations
    /// would mean re-deriving them when the filter lands.
    AgentOnly,

    One correction to the issue's numbers: it says AgentOnly has "three real constructors". On main there is one in-tree constructor — src/openhuman/memory/agent/tools.rs:91. The other occurrences are not constructors: src/openhuman/runtime/node/ops.rs:16 maps the variant to the label "agent_only", and the remaining two are assertions in runtime/node/ops_tests.rs:77 and integrations/mod_tests.rs:13. That weakens the "losing those annotations would mean re-deriving them" argument considerably — one annotation is not much to re-derive, so collapsing to All is a more attractive option now than when this was filed.

    is_concurrency_safe is unchanged: still implemented across the read-only tools (network/web_fetch.rs:109, filesystem/grep.rs:76, filesystem/glob_search.rs:85, filesystem/file_read.rs:49, memory/agent/tools.rs:94) and still never read for dispatch — the tool loop remains serial.

    Also worth disambiguating for whoever picks this up: there is now a second, unrelated ToolScope in the tree — src/openhuman/agent/harness/definition_part_01.rs:594 (Wildcard / Named(Vec<String>)), which scopes which tools a sub-agent may see. Same name, different concept. A grep for ToolScope will hit both.


    Suggested sequencing

    Items 1 and 2 are independent and local(ish); item 3 now has a vendor dependency. If the aim is to close acceptance criteria incrementally, item 1 first — it is self-contained, the test that pins the current contract is named, and either decision is a small PR. Item 3's scope should probably be restated in the body to reflect the tinytools move before anyone estimates it.

  4. added
    triage: needs-opinion
    on Oct 9, 2026
  5. senamakel commented on Oct 9, 2026

    @senamakel
    MemberAuthor

    Triage: needs opinion — “Resolve the three deferred TinyAgents §5 design decisions (recommend_tier, NotOwned, ToolScope/is_concurrency_safe)” needs a maintainer decision on product scope/priority or fresh reproduction evidence before its status can be settled. Please advise whether to pursue, narrow, or close it.

  6. added
    source: team
    on Oct 9, 2026
  7. M3gA-Mind commented on Nov 16, 2026

    @M3gA-Mind
    Collaborator

    Thanks for keeping this precise. Re-checked on current main, the three items have moved on:

    1. recommend_tier RAM scaling: the function no longer exists in OpenHuman. It moved out in Move reusable inference implementation out of OpenHuman #6326, and the cap was later removed upstream.
    2. SteerError::NotOwned on the RPC path: the steer RPC was removed in [tinyagents-slim] complete OpenHuman host adoption #8319, and ownership is now explicit in TinyAgents (SteerAccess::Owner vs Trusted), so the ambiguity is gone. (crates/openhuman-core/src/agent/README.md still lists steer and could be updated.)
    3. ToolScope::AgentOnly / is_concurrency_safe: these live in TinyTools/TinyAgents now. is_concurrency_safe is in use for concurrent tool batches, while AgentOnly is still not enforced.

    Since nothing here remains in this repository, we're closing this one. If AgentOnly enforcement is still wanted, it belongs in a TinyTools issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rust-coresource: teamtriage: needs-opinion

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions