Skip to content

refactor(agent): adopt tinytools NativeToolCall in place of the host ToolCall shim - #6806

Merged
senamakel merged 8 commits into
tinyhumansai:mainfrom
senamakel:vendor-extract-w3-messages
Sep 30, 2026
Merged

senamakel merged 8 commits into
tinyhumansai:mainfrom
senamakel:vendor-extract-w3-messages

Conversation

@senamakel

@senamakel senamakel commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

This is part of Wave 3's work to adopt vendor message types. It replaces OpenHuman's ToolCall with tinytools_agent::dialect::NativeToolCall, the one type that is field-for-field and serde-identical to its vendor counterpart. Every other message type is a product or persisted contract, so it stays in OpenHuman, with the reasons below.

Changes

  • ToolCall is deleted from inference/provider/types.rs. ChatResponse.tool_calls and ConversationMessage::AssistantToolCalls now hold NativeToolCall.
  • Call sites import it directly. There is no re-export.
  • message_convert.rs no longer copies tool calls field by field.
  • A literal-JSON fixture (conversation_tool_calls_serde_matches_persisted_literal_json) loads legacy AssistantToolCalls records, with and without extra_content, and re-serializes them to the identical bytes. Persisted and provider wire formats are unchanged.

Types that stay in OpenHuman

Type Why it stays
ChatMessage, ConversationMessage, ToolResultMessage The persisted transcript and thread format, with OpenHuman-only fields such as cache_breakpoints and host metadata keys. Replacing them means moving the session journal to vendor Message or TranscriptMessage, which is a design change.
ChatResponse Needs DialectResponse extended upstream with usage and reasoning_content.
ProviderDelta OpenHuman's streaming contract. It has no vendor equivalent.
UsageInfo Already a tinymemory-api type. Mapping it to tinyinference_llm::usage::Usage needs an owner for charged_amount_usd.

Verification

  • cargo check --tests -p openhuman -p openhuman-cli --features "$(bash scripts/ci/product-features.sh)" is clean. The app manifest, embed and tinyhumans also compile.
  • json_rpc_e2e (full run), agent_harness_e2e and transcript_search_e2e all pass. The harness count matches main apart from its known failures.
  • Full lib suite: only the known goals test fails consistently. Three other tests failed once in a full run and pass in isolation: load_and_apply_autonomy_settings_roundtrip, tool_timeout_seeds_on_channelless_core_boot and explicit_scratch_workspace_cannot_activate_operator_user. None of them touch message types.
  • No submodule or pin changes.

Failures that are already on main

These reproduce on main, and every one of them was also checked at an earlier baseline:

  • Lib suite: agent::goals::tools::tests::set_persists_to_the_workspace_store_and_answers_goal_and_text, fixed in test(goals): read structured goal tool results via output() #6803.
  • raw_coverage_all: the MCP test tool_registry_entries_include_connected_mcp_client_tools.
  • agent_harness_e2e: orchestrator_advertises_direct_mcp_tools, orchestrator_cannot_install_a_skill_through_the_raw_registry_tool and orchestrator_hands_skill_installs_to_skill_setup_directly. These fail identically at e80051674e, the test: drop 45 quarantined raw-coverage files, dedupe vendor-covered tests, repoint vendor pins #6781 merge, which is before any of the vendor-extraction PRs.
  • rust:layout: runtime_session.rs is 1994 lines against a limit of 1990. openhuman_backend_model{,_tests}.rs are 759 and 761 against 750.
  • check-agent-runtime-boundary: the existing violations in openhuman_backend_model.rs, json_schema/ops.rs and tools/impl/meta/mod.rs.
  • check-module-pins: tinychannels.

Summary by CodeRabbit

  • Refactor
    • Unified internal handling of assistant tool calls across responses, conversation history, and transcripts. Existing tool-call details, including provider-specific metadata, continue to be preserved. This update changes internal consistency only; tool-call behavior and conversation history remain unchanged for users.

senamakel and others added 8 commits September 30, 2026 13:07
…eToolCall

Removed the locally defined ToolCall struct from the provider types module and replaced all usages with the NativeToolCall type from the tinytools_agent dialect crate. This eliminates duplicated type definitions and aligns the codebase with the shared tool-call representation used across the agent system, reducing maintenance overhead and ensuring consistent serialization behavior.

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

Updated the tool call type used throughout message conversion and session host runtime to `tinytools_agent::dialect::NativeToolCall` instead of the local `crate::inference::provider::ToolCall`. This aligns the codebase with the canonical type definition from the tinytools agent crate, reducing duplication and ensuring consistency with the external tool call representation.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Removed several test files that were no longer needed, cleaning up the test suite by deleting stale or redundant test modules.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
When converting messages, the implementation now correctly handles cases where message content is empty by returning an appropriate default value instead of failing or producing unexpected results.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update test files to remove unused imports and fix unused variable warnings that were causing compilation errors. The changes clean up test code by removing unnecessary imports and replacing unused variables with underscores to ensure tests compile cleanly.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a test that verifies a persisted JSON literal for `ConversationMessage::AssistantToolCalls` can be deserialized and then serialized back to the identical string, ensuring the format remains stable now that tool calls use the dialect crate's `NativeToolCall`.

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

Updated test fixtures across five files to use `NativeToolCall` instead of `ToolCall` when constructing tool responses, and removed the now-unused `NativeToolCall` import from `message_convert.rs`. This aligns the test code with the renamed type and eliminates a dead import.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Two doc comments in message_convert.rs referred to the openhuman `ToolCall` type, but the actual types used in the adjacent functions are `NativeToolCall`. Updated the documentation to match the real type signatures, preventing confusion for readers.

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.

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: b235f83d-8f6d-4e21-aebd-b6a256ea4b6c

📥 Commits

Reviewing files that changed from the base of the PR and between cc8c966 and f726d91.

📒 Files selected for processing (15)
  • crates/openhuman-core/src/agent/agent_tests.rs
  • crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs
  • crates/openhuman-core/src/agent/agent_turn_loop_packed_tool_tests.rs
  • crates/openhuman-core/src/agent/agent_turn_loop_tests.rs
  • crates/openhuman-core/src/agent/harness/parse_tests.rs
  • crates/openhuman-core/src/agent/harness/parse_wire_tests.rs
  • crates/openhuman-core/src/agent/message_convert.rs
  • crates/openhuman-core/src/agent/message_convert_tests.rs
  • crates/openhuman-core/src/agent/messages.rs
  • crates/openhuman-core/src/agent/session_host/runtime/turn_helpers.rs
  • crates/openhuman-core/src/agent/subagent_host/ops/graph_policy_tests.rs
  • crates/openhuman-core/src/flows/ops_tests.rs
  • crates/openhuman-core/src/inference/provider/mod.rs
  • crates/openhuman-core/src/inference/provider/types.rs
  • crates/openhuman-core/src/threads/transcript_host_tests.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

The provider response and persisted assistant-message contracts now use the dialect NativeToolCall type. Conversion and history helpers, along with test fixtures, were updated to use this type.

Changes

Native tool-call type migration

Layer / File(s) Summary
Response and message contracts
crates/openhuman-core/src/inference/provider/{types.rs,mod.rs}, crates/openhuman-core/src/agent/messages.rs
ChatResponse.tool_calls and ConversationMessage::AssistantToolCalls.tool_calls now use NativeToolCall. The provider module no longer re-exports ToolCall.
Conversion and history helpers
crates/openhuman-core/src/agent/message_convert.rs, crates/openhuman-core/src/agent/session_host/runtime/turn_helpers.rs
Conversion helpers and persisted history construction now use NativeToolCall. Response-provided calls are cloned directly; parsed calls are mapped into the native type.
Test helpers and fixtures
crates/openhuman-core/src/agent/agent*_tests.rs, crates/openhuman-core/src/agent/harness/*_tests.rs, crates/openhuman-core/src/agent/message_convert_tests.rs, crates/openhuman-core/src/agent/subagent_host/ops/graph_policy_tests.rs, crates/openhuman-core/src/flows/ops_tests.rs, crates/openhuman-core/src/threads/transcript_host_tests.rs
Test helpers and fixtures now use NativeToolCall. A serialization test checks that persisted assistant tool-call JSON reproduces the supplied literal.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: m3ga-mind

Merge Risk: ⚪ Minimal · up to f726d

The migration preserves tool-call metadata on the changed conversion path, and no in-workspace build consumer depends on the removed re-export. No concrete merge-blocking regression is established; the change appears ready to merge subject to normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to f726d

The reviewed paths preserve existing tool-call identity, ordering, and trust controls. No introduced security weakness was established, but compatibility with stored conversations could not be fully confirmed.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The migration affects tool-call records carried by provider responses and persisted assistant history, rather than introducing a new execution authority. Shared consumers inherit the dependency-owned representation, but expanded tenant, credential, or deployment exposure was not established.

Trust Boundaries and Controls

  • observed — Persisted history still passes through ToolDialect for provider conversion. Assistant-envelope parsing requires a non-empty parseable call array, unknown roles fall back to user, and converted tool results remain explicitly untrusted. These controls are unchanged in the reviewed paths; exact dependency deserialization constraints remain unverified.
🚥 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 describes the main change: replacing the host ToolCall shim with tinytools_agent::dialect::NativeToolCall in agent code.
Docstring Coverage ✅ Passed Docstring coverage is 87.88% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 15 files.
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 each call in line,
Native fields now match the sign.
Through history, tests, and turns they go,
Their signatures still in tow.
Then back to JSON, neat as before.

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

@tinysweeper

tinysweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

⚠️ Review failed for f726d9125fd6. the review of #6806 did not finish within 900s

@senamakel
senamakel merged commit cc2b839 into tinyhumansai:main Sep 30, 2026
30 of 33 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