Skip to content

feat(harness): add ToolExecutionContext::call_id_of and PackRegistryHandle::of - #616

Open
CodeGhost21 wants to merge 1 commit into
tinyhumansai:mainfrom
CodeGhost21:feat/93-call-id-accessors
Open

CodeGhost21 wants to merge 1 commit into
tinyhumansai:mainfrom
CodeGhost21:feat/93-call-id-accessors

Conversation

@CodeGhost21

@CodeGhost21 CodeGhost21 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds two accessors so hosts stop hand-rolling downcasts of harness types:

  • ToolExecutionContext::of(context: Option<&dyn ToolRunContext>) -> Option<&Self>: the one documented downcast through ToolRunContext::host_extension. ToolExecutionContext::call_id_of(context) -> Option<String> reads the call id through it.
  • PackRegistryHandle::of(tool: &dyn Tool) -> Option<Self>: reads the handle UseSkillTool::new attaches as metadata on the tool's ToolCallBinding. The existing skills::pack_registry_handle free function now calls it, so it stays public and works as before.

media/artifact_tool.rs::canonical_tool_call_id uses call_id_of instead of its own copy of the downcast, with an identical result.

OpenHuman's crates/openhuman-core/src/tools/host_extensions.rs exists only to do these two downcasts. Its tool_call_id(ctx) and pack_registry_handle(tool) map 1:1 onto ToolExecutionContext::call_id_of and PackRegistryHandle::of, with the same input and output types (host adoption: senamakel/openhuman#363).

Fixes senamakel#93. Part of tinyhumansai/openhuman#7390 (phase 3 tracker senamakel/openhuman#391).

API Or Behavior Changes

  • New public functions:
    • tinyagents_harness::tool::ToolExecutionContext::{of, call_id_of}
    • tinyagents_harness_tools::skills::PackRegistryHandle::of
  • No behaviour change: pack_registry_handle and canonical_tool_call_id delegate to the new accessors.
  • PackRegistryHandle::of lives in tinyagents-harness-tools, beside PackRegistryHandle, not in tinyagents-harness/src/tool/ as the issue's target column says. That crate is where the type and its free-function downcast already were.
  • Open question: call_id_of returns Option<String> to match OpenHuman 1:1. A borrowing form is already available as ToolExecutionContext::of(ctx).map(|c| &c.call_id).

Tests

  • tinyagents-harness/src/tool/context_tests.rs, 4 new:
    • call_id_of_reads_the_harness_execution_context and call_id_of_is_none_without_a_context, which are OpenHuman's tool_call_id tests, adapted;
    • of_recovers_the_harness_context_from_the_erased_run_context, which checks pointer identity;
    • of_is_none_without_a_context_or_for_a_foreign_context.
  • tinyagents-harness-tools/src/skills/mod_tests.rs, 2 new:
    • of_returns_the_handle_use_skill_was_built_with;
    • of_is_none_for_a_tool_without_a_pack_registry_handle.

Commands run locally:

  • cargo fmt --check (cargo fmt --all -- --check)
  • cargo clippy --all-targets -- -D warnings (--workspace)
  • cargo clippy --all-targets --all-features -- -D warnings (--workspace)
  • cargo build --all-targets (cargo check -p tinyagents-harness -p tinyagents-harness-tools)
  • cargo build --all-targets --all-features: left to CI
  • cargo test, scoped:
    • -p tinyagents-harness --lib tool::: 309 passed.
    • -p tinyagents-harness-tools --all-features --lib media::: 10 passed.
    • -p tinyagents-harness-tools --lib -- skills::: 30 passed, 5 failed. The 5 fail identically on unmodified upstream/main (28cf21e) with "packed tool catalog is unavailable for this registration":
      • typed_use_skill_dispatch_pins_the_selected_target_and_live_parent
      • pinned_pack_call_merges_outer_approval_and_shared_adapter_forwards_binding
      • generic_binding_applies_tool_rules_to_the_selected_packed_tool
      • harness_rule_denial_blocks_the_pinned_inner_tool_before_typed_dispatch
      • registered_pack_dispatch_runs_through_the_harness_with_admitted_target_and_live_parent
    • These need their own issue.
  • cargo test --all-features: left to CI

Documentation

  • CHANGELOG.md: new "Unreleased" entry.
  • One-line notes in crates/tinyagents-harness/src/tool/README.md and crates/tinyagents-harness-tools/README.md.

Release note: OpenHuman needs a tag that contains this before it can bump the gitlink, swap its callers and delete tools/host_extensions.rs.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a way to retrieve the harness execution context and provider-assigned call ID from a tool context.
    • Added a way to retrieve the shared skill registry handle from a registered tool. The existing skills::pack_registry_handle function remains available.
  • Documentation
    • Updated tool and skills documentation with guidance on retrieving execution context, call IDs, and shared registry handles.

…andle::of

Hosts recovered the harness call id and the use_skill pack-registry handle
with their own downcasts over tinytools' erased host-extension seams.
Expose the accessors on the owning types instead:

- ToolExecutionContext::of(Option<&dyn ToolRunContext>) is the single
  host_extension downcast; call_id_of returns the call id through it.
- PackRegistryHandle::of(&dyn Tool) reads the handle UseSkillTool attaches
  as ToolCallBinding metadata; skills::pack_registry_handle delegates to it.

The media artifact tool's call-id extraction now uses call_id_of.

Refs senamakel#93

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The pull request adds methods to recover a harness execution context, its call ID, and a skills pack registry handle from tool inputs. It updates artifact tooling to use the call-ID method and adds tests, documentation, and changelog entries.

Changes: Tool Accessors

Layer / File(s) Summary
Execution context accessors
crates/tinyagents-harness/src/tool/types.rs, crates/tinyagents-harness/src/tool/context_tests.rs, crates/tinyagents-harness/src/tool/README.md, crates/tinyagents-harness-tools/src/media/artifact_tool.rs, CHANGELOG.md
ToolExecutionContext::of recovers the harness context, and call_id_of returns its call ID as a string. Artifact tooling uses call_id_of. Tests cover successful recovery and absent or foreign contexts.
Pack registry handle accessor
crates/tinyagents-harness-tools/src/skills/tool.rs, crates/tinyagents-harness-tools/src/skills/mod_tests.rs, crates/tinyagents-harness-tools/README.md
PackRegistryHandle::of recovers a registry handle from a registered tool. The existing free function delegates to it. Tests cover handle sharing and unrelated tools.

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

Change: Feature

Suggested reviewers: senamakel, tinysweeper

Merge Risk: Minimal · up to b2358

This adds public accessors for recovering a call ID and a pack registry handle, and existing helpers now delegate to them with the same behavior. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names two public accessors, ToolExecutionContext::call_id_of and PackRegistryHandle::of. The changeset adds both methods, plus tests, docs, and changelog entries, and it switches existing he…
Linked Issues check Passed Issue #93 requires two coding changes: add ToolExecutionContext::call_id_of and PackRegistryHandle::of, and move the OpenHuman tests for these downcasts. The PR adds both accessors. `ToolExecution…
Out of Scope Changes check Passed All changed files connect to the issue. The accessors and their tests implement #93. The pack_registry_handle and canonical_tool_call_id changes replace duplicate downcasts with the new accessors …
Full details: Title check

Explanation

The title names two public accessors, ToolExecutionContext::call_id_of and PackRegistryHandle::of. The changeset adds both methods, plus tests, docs, and changelog entries, and it switches existing helpers to use them. The title covers the main change. It does not mention the delegation refactors, but it does not need to cover every detail. It uses the conventional feat(harness) scope, which is accurate for the harness crate. The title is specific and matches the changeset.

Full details: Linked Issues check

Explanation

Issue #93 requires two coding changes: add ToolExecutionContext::call_id_of and PackRegistryHandle::of, and move the OpenHuman tests for these downcasts. The PR adds both accessors. ToolExecutionContext::of and call_id_of are in crates/tinyagents-harness/src/tool/types.rs. PackRegistryHandle::of is in crates/tinyagents-harness-tools/src/skills/tool.rs. Tests cover both accessors: 4 in context_tests.rs (two adapted from OpenHuman's tool_call_id tests) and 2 in skills/mod_tests.rs. The existing pack_registry_handle and canonical_tool_call_id now delegate to the new accessors. Two points need a note. First, PackRegistryHandle::of lives in tinyagents-harness-tools, not in tinyagents-harness/src/tool/ as the issue target column states. The PR gives a reason: the type and its existing downcast already live in that crate. Second, the Definition of done asks for green repo CI. The PR reports 5 failing skills tests locally. It reports that the same tests fail on unmodified base 28cf21e3d, so the PR does not introduce them. The --all-features build and test runs were left to CI, so that part is unverified here. The release/tag and OpenHuman gitlink steps are non-coding and do not apply.

Full details: Out of Scope Changes check

Explanation

All changed files connect to the issue. The accessors and their tests implement #93. The pack_registry_handle and canonical_tool_call_id changes replace duplicate downcasts with the new accessors and keep their behavior. The README and CHANGELOG edits document the new public API. No unrelated behavior change is reported. The call_id_of return type (Option&lt;String&gt;) matches the OpenHuman helper 1:1, as the issue requires. The PR raises a borrowing-form question as an open item. That is an API design note, not out-of-scope work.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit finds the context key
And reads the call ID carefully
A registry handle joins the run
Tests confirm the work is done
The rabbit hops beneath the moon

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fc58a275-b2ab-4db7-9b94-513ecebf6ae0
Commits

Reviewing files that changed from the base of the PR and between 28cf21e and b23586f.

Files selected for processing: 8

  • CHANGELOG.md
  • crates/tinyagents-harness-tools/README.md
  • crates/tinyagents-harness-tools/src/media/artifact_tool.rs
  • crates/tinyagents-harness-tools/src/skills/mod_tests.rs
  • crates/tinyagents-harness-tools/src/skills/tool.rs
  • crates/tinyagents-harness/src/tool/README.md
  • crates/tinyagents-harness/src/tool/context_tests.rs
  • crates/tinyagents-harness/src/tool/types.rs

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

@CodeGhost21
CodeGhost21 marked this pull request as ready for review November 16, 2026 14:12

This branch has not been deployed

No deployments
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.

[core-shrink] upstream: ToolExecutionContext::call_id_of and PackRegistryHandle::of

1 participant