Skip to content

refactor(agent): move tool-result artifacts and the use_skill pack mechanism into tinyagents-harness - #6797

Merged
senamakel merged 13 commits into
tinyhumansai:mainfrom
senamakel:vendor-extract-w2-artifacts
Sep 30, 2026
Merged

senamakel merged 13 commits into
tinyhumansai:mainfrom
senamakel:vendor-extract-w2-artifacts

Conversation

@senamakel

@senamakel senamakel commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

This Wave 2 PR moves the tool-result artifact store and the use_skill tool-pack mechanism into tinyagents-harness. The net change is −1.85k lines (197 added, 2,049 deleted).

Stacked on #6789 (→ #6786 → #6785). Upstream branch creation is restricted, so the base is main.

Tool-result artifacts → tinyagents_harness::artifacts::tool_results (tinyagents#239)

  • Moved: oversized tool output → artifact file + preview envelope + paged reads. It reuses the crate's existing ArtifactRedactor/Redacted rather than adding a second policy trait.
  • Seam: ToolResultArtifactStore::new(action_dir, session, Arc<dyn ArtifactRedactor>, read_tool, max_readable_bytes). The file_read/use_skill names are passed as parameters.
  • OpenHuman keeps a 62-line wiring module. It passes the existing SanitizingRedactor, FileReadTool::MAX_FILE_SIZE_BYTES, and the openhuman_tool_result_artifacts namespace.
  • Envelope, page trailer and paths are unchanged. A literal fixture test pins the envelope (envelope_text_is_byte_stable). The OpenHuman index store is replaced by the crate's InMemoryStore.
  • Not moved: artifact_offload/. What remains there is host-owned by design: the SecurityPolicy workspace guard, the sanitize_text redactor, and the product prompt text.

use_skill pack mechanism → tinyagents_harness::tool::packs

  • Moved: ToolPack, PackCatalog, PackRegistryHandle, UseSkillTool, render_pack_filtered, scope_use_skill_spec, route_sentence, NoSuchPackTool and USE_SKILL.
  • Seam: PackCatalog::new(&'static [ToolPack], not_found_marker).
  • Tool name, description and schema are byte-identical, pinned by a literal test.
  • Stays in OpenHuman:
    • the product pack table (registry.rs, PACKS);
    • ToolGroups, which is sized by the table and reads CoreContext;
    • the strip/close/bind ops over host_extensions and ToolPolicySession.
  • CoreBuilder's API is unchanged.
  • Call sites import tinyagents_harness::tool::packs directly, because the boundary check bans re-exports.

Web-chat error classifiers: not moved

  • The ladder is product copy and wire tokens: the per-hour action budget text, "Connections → API keys → LLM", and openhuman_billing. The predicates are keyed on OpenHuman's own backend strings.
  • The one exact duplicate, is_non_retryable_rate_limit_text, was a byte-identical copy of tinyinference's private contains_business_limit. That function is now public (tinyinference#42), and retry.rs delegates to it.

Verification

  • cargo check --tests -p openhuman -p openhuman-cli --features "$(bash scripts/ci/product-features.sh)" is clean. The app manifest and openhuman-embed/openhuman-tinyhumans --tests also compile.
  • Full lib suite with the product features: 10344 passed, 1 failed. The failure is the known sync_activity ordering race (see refactor(core): move time/goals tools, conversation store and composio execute into vendor crates #6785).
  • raw_coverage_all: 167 passed, 1 failed. The failure is the pre-existing MCP tool_registry_entries_include_connected_mcp_client_tools, which fails identically on the original base.
  • Vendor: tinyagents artifacts::tool_results has 21 tests, tool::packs has 16, and tinyinference failure has 14. fmt and clippy -D warnings are clean.
  • These pass: rust:layout, check-agent-runtime-boundary, check-feature-forwarding, check-gated-test-allowlist, and check-submodule-monotonic upstream/main HEAD.

Merge order

Merge tinyinference#42 first, then tinyagents#239 (both based on main), then this PR after #6789.

Summary by CodeRabbit

  • Bug Fixes

    • Improved recognition of business-limit errors so retry behavior handles these responses more consistently.
  • Improvements

    • Updated tool-result artifact handling and skill routing while preserving their existing behavior. This helps keep tool results and skill access working consistently across the app.

senamakel and others added 12 commits September 30, 2026 10:26
Updates the vendored tinyagents dependency to the latest version to incorporate upstream bug fixes and improvements.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The `UseSkillTool`, `PackRegistryHandle`, and `ToolPack` types, along with their rendering and resolution logic, have been moved from the local `toolpacks` module into the `tinyagents_harness` crate. The local `tools.rs` and `types.rs` files are deleted, and all call sites now import from `tinyagents_harness::tool::packs`. A new `CATALOG` constant in `registry.rs` wraps the static `PACKS` array into a `PackCatalog` that the generic `use_skill` tool uses for lookup, keeping the pack definitions local while delegating the tool infrastructure to the shared harness.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…ts_harness::tool::packs::USE_SK

Migrate all references to the `USE_SKILL` constant and related tool pack types from the internal `crate::tools::toolpacks` module to the external `tinyagents_harness::tool::packs` crate. This change aligns the codebase with the extracted harness library, ensuring that tool pack definitions and their associated types are sourced from the shared dependency rather than the local module.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The packed tool route middleware was incorrectly using the original tool name instead of the packed tool name when routing tool calls. This caused tool dispatch to fail for tools that had been packed, as the middleware could not match the incoming tool name to the registered packed tool identifier.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
When a tool returns a result artifact referencing a file that does not exist on disk, the agent now gracefully handles the missing file instead of panicking. This change adds proper error handling in the tool result artifacts module and updates the session host builder and tool policy middleware to propagate the error correctly, ensuring robust behavior in production scenarios where file system state may not match tool outputs.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The tool result artifacts module and its associated wiring were no longer being used after the migration to the tinyagents middleware architecture. This change removes the dead code to reduce maintenance burden and improve code clarity.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…_harness

Migrate the `USE_SKILL` constant, `route_sentence`, `scope_use_skill_spec`, and `render_pack_filtered` functions along with their associated tests from the core toolpacks crate into the `tinyagents_harness` crate. This centralizes test infrastructure for pack-related tooling and removes duplicate or dead test code from the core library, keeping the production codebase focused on runtime behavior rather than test scaffolding.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
…e_llm

Replace the inline list of business-limit markers and Z.AI codes in `is_non_retryable_rate_limit_text` with a call to `tinyinference_llm::failure::contains_business_limit`, which now owns the canonical detection logic. This removes duplication and ensures the web-chat layer stays in sync with the provider classification without maintaining a separate copy of the marker set.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reordered import statements in thirteen files to follow the project's convention of grouping third-party imports before local crate imports, with no functional changes to the code.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updated the vendored tinyagents dependency to incorporate upstream fixes and improvements. No changes to the project's own source code were required.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add README documentation for the agent harness and toolpacks modules to improve developer onboarding and clarify the purpose and usage of these components within the openhuman-core crate.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 2ba2c75b-cbcb-4db1-b9d7-7c889a188a92

📥 Commits

Reviewing files that changed from the base of the PR and between 1f8a8cc and b9eabac.

📒 Files selected for processing (4)
  • crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.rs
  • crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
  • crates/openhuman-core/src/tools/toolpacks/registry.rs
  • vendor/tinyagents
 ______________________________________________________________________________________________
< Rabbits with frickin' laser beams attached to their heads. And they're pointed at your bugs. >
 ----------------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: be814743-64dc-4d48-9c7c-5e18b0db1b6e

📥 Commits

Reviewing files that changed from the base of the PR and between e43974c and 1f8a8cc.

📒 Files selected for processing (35)
  • crates/openhuman-core/src/agent/harness/README.md
  • crates/openhuman-core/src/agent/harness/tool_result_artifacts/mod.rs
  • crates/openhuman-core/src/agent/harness/tool_result_artifacts/mod_tests.rs
  • crates/openhuman-core/src/agent/registry/agents/fleet_prompt_tests.rs
  • crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.rs
  • crates/openhuman-core/src/agent/session_host/artifact_wiring.rs
  • crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs
  • crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs
  • crates/openhuman-core/src/agent/session_host/builder/mod.rs
  • crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
  • crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs
  • crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
  • crates/openhuman-core/src/agent/tinyagents/middleware/artifact_index_toc.rs
  • crates/openhuman-core/src/agent/tinyagents/middleware/packed_tool_route.rs
  • crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
  • crates/openhuman-core/src/agent/tinyagents/middleware/tool_output_tests.rs
  • crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs
  • crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
  • crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_artifact_tests.rs
  • crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs
  • crates/openhuman-core/src/agent/tinyagents/middleware_wrap_up_toc_tests.rs
  • crates/openhuman-core/src/agent/tinyagents/use_skill_dispatch.rs
  • crates/openhuman-core/src/agent/tinyagents/use_skill_dispatch_tests.rs
  • crates/openhuman-core/src/tools/host_extensions.rs
  • crates/openhuman-core/src/tools/toolpacks/README.md
  • crates/openhuman-core/src/tools/toolpacks/mod.rs
  • crates/openhuman-core/src/tools/toolpacks/ops.rs
  • crates/openhuman-core/src/tools/toolpacks/registry.rs
  • crates/openhuman-core/src/tools/toolpacks/toolpacks_tests.rs
  • crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rs
  • crates/openhuman-core/src/tools/toolpacks/tools.rs
  • crates/openhuman-core/src/tools/toolpacks/types.rs
  • crates/openhuman-core/src/web_chat/web_errors/retry.rs
  • tests/raw_coverage/tools_erased_host_extension_raw_coverage_e2e.rs
  • vendor/tinyagents
💤 Files with no reviewable changes (2)
  • crates/openhuman-core/src/tools/toolpacks/types.rs
  • crates/openhuman-core/src/tools/toolpacks/tools.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

OpenHuman now delegates tool-result artifact storage and tool-pack behavior to TinyAgents, while retaining host-specific configuration and registry data. The rate-limit error check uses TinyInference’s shared business-limit detection helper.

Changes

TinyAgents Harness Migration

Layer / File(s) Summary
Configure the harness artifact store
crates/openhuman-core/src/agent/harness/..., crates/openhuman-core/src/agent/session_host/artifact_wiring.rs, crates/openhuman-core/src/agent/tinyagents/...
OpenHuman supplies the redactor, tool names, and file-size limit to the harness artifact store. Store construction and artifact-index wiring use TinyAgents types. Tests cover artifact-read detection and continuation output; the README describes the updated ownership.
Move tool-pack APIs to TinyAgents
vendor/tinyagents, crates/openhuman-core/src/tools/toolpacks/...
The host registry builds and exports CATALOG from PACKS, and delegates pack operations to it. Local tool-pack implementations and types are removed. Construction and scoping tests use TinyAgents APIs; several local dispatch and routing tests are removed.
Update tool-pack consumers
crates/openhuman-core/src/agent/registry/agents/..., crates/openhuman-core/src/agent/session_host/builder/..., crates/openhuman-core/src/agent/tinyagents/..., crates/openhuman-core/src/tools/host_extensions.rs, tests/raw_coverage/...
Routing, policy, dispatch, host extensions, and tests import pack APIs from TinyAgents. Tool construction passes the catalog where required.

Business-Limit Error Detection

Layer / File(s) Summary
Use shared business-limit detection
crates/openhuman-core/src/web_chat/web_errors/retry.rs
The rate-limit check calls tinyinference_llm::failure::contains_business_limit instead of checking local text markers and numeric codes.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Suggested reviewers: m3ga-mind

Merge Risk: ⚪ Minimal · up to 1f8a8

This change moves tool-result artifact storage and tool-pack behavior into shared libraries while keeping OpenHuman's configuration and pack data. It also reuses the shared rate-limit detection. No concrete regression was identified, so the change appears ready to merge after normal checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 1f8a8

Existing permission checks and data-protection settings remain visible, and no new security issue was verified. However, equivalent protections during writes, interrupted operations, and cleanup have not been fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated sensitive sink is the host-selected workspace filesystem, with metadata exposed through the run store. The host chooses the workspace descriptor root when present and otherwise action_dir, and supplies a session key. Maximum independently attackable scope and cross-session or tenant isolation remain unresolved without the delegated containment logic and complete runtime input provenance.

Trust Boundaries and Controls

  • observed — For model-selected use_skill calls, host middleware checks pack ownership, registered inner-tool existence, session callability, permission ceilings, and policy before execution. Disclosure rendering also occurs after the gates. Session-visible schemas use copy-on-write narrowing rather than modifying shared durable schemas. The extraction evidence does not establish a newly introduced authorization bypass.

Resilience and Maintainability Implications

  • inferred — Publication follows a successful persistence outcome, but equivalence under partial writes, cancellation, duplicate or concurrent call IDs, cleanup races, and recovery is unresolved. The base already used a direct filesystem write; absent atomicity guarantees must therefore not be reported as an extraction-introduced defect without further comparison.

Hardening Proposals

  • proposed — Make the pinned shared-library enforcement contract independently reviewable, including redaction before storage and preview exposure, containment and session-path normalization, sanitized-size bounds, and lifecycle behavior under interruption, repetition, concurrency, and pruning. Treat additional atomic-write or reconciliation mechanisms as hardening unless comparison demonstrates a regression.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main changes: moving tool-result artifacts and the use_skill pack mechanism into tinyagents-harness.
Docstring Coverage ✅ Passed Docstring coverage is 83.67% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 49 functions across 30 files. (3 skipped: 3…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

A rabbit checks the tool-pack trail
Tiny stores now hold the tale
Redactor guards each artifact page
Catalogs guide the tools on stage
Shared limit checks hop through the code
Then I nibble clover by the road

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 30, 2026
Pin tinyagents at the artifacts tip merged with main (oh-stack-6797).

Co-authored-by: Medulla <medulla@tinyhumans.ai>
@senamakel
senamakel merged commit cc8c966 into tinyhumansai:main Sep 30, 2026
25 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant