Repository navigation
tinyagents-hooks: new crate holding every hook type #470
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or requestpriority: p3Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.rustPull requests that update rust codePull requests that update rust code
Description
OpenHuman wants every hook to live in the harness (from openhuman#7929). Create crates/tinyagents-hooks. It depends on tinyagents-harness, and tinyagents-runtime depends on it.
Contents
tool/: a typed in-processToolHook<Ctx>(before_tool_decision/before_tool/after_tool/after_tool_context),ToolHookContext,ToolHooksMiddleware<Ctx>, aHookIdentityextractor trait (session_id,agent_id,cwd) andsanitize_tool_output.- One
ToolHookDecisiontype, unified with the command-hook allow / deny / ask / updated_input / additional_context vocabulary. - Source: OpenHuman
agent/hooks.rs(383 lines) andagent/tinyagents/middleware/embedder_hooks.rs(258).
- One
command/: movetinyagents-runtime/src/command_hooks/here. It is self-contained and imports onlysuper::.HookEngineimplementsToolHookdirectly.- Absorb the derived-event mapping from OpenHuman
src/hooks/bridge.rs(373) and the lifecycle entry pointssession_started,prompt_submitted,pre_compactandsubagent_*fromsrc/hooks/ops.rs(263).
stop/: moveharness/src/middleware/library/stop_hooks/andstop_latch.rshere, along withimpl StopHookMetrics for TurnCost.- Add a stock
BudgetStopHook(OpenHumanagent/stop_hooks.rs) andGoalBudgetStopHook(OpenHumanagent/goals/runtime.rs, takingArc<dyn Store>, behind agoalsfeature). - Add
StopHookMiddleware::with_halt_summary(slot)(OpenHumanagent/tinyagents/stop_hooks.rs).
- Add a stock
lifecycle/: moveharness/src/middleware/library/lifecycle_hooks/here.turn/: post-turn hooks folded intoLearningSink.- Extend
TurnSummarywith per-tool outcome records: name, args digest, success, classified failure, duration. - Add parallel
fire_*dispatch. - This replaces OpenHuman's
PostTurnHook/TurnContext.
- Extend
scope.rs:HookScope, the per-turn tool, learning and stop hook lists (OpenHumanagent/hooks_scope.rs). Also addFnSessionHooks<C>, a closure-backedSessionHooks(OpenHumanagent/session_host/hooks.rs).
Compat
tinyagents-runtimere-exportscommand_hooksfor one release.- Moving the harness
middleware::StopHookpaths is a breaking change: bump the minor version, add a CHANGELOG entry, and adddocs/modules/hooks/README.md. - Add the crate to the workspace
default-members.
Done when: merged upstream with tests in sibling *_tests.rs, released or tagged, and the OpenHuman follow-up can delete the host copy after a gitlink bump on vendor/tinyagents.
Parent: tinyhumansai/openhuman#7929, which has the full file-by-file verdict tables.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestpriority: p3Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.rustPull requests that update rust codePull requests that update rust code
Activity
tinysweeper commentedon Oct 16, 2026
Create a new tinyagents-hooks crate consolidating tool, command, stop, lifecycle, turn, and scope hook types, moved/derived from existing runtime and harness code plus OpenHuman host copies. This is a large re-architecting/refactor task, not a bug; it is an enhancement-level effort with no user-facing breakage beyond a planned minor-version bump, so p3.
Labelled
priority: p3.senamakel commentedon Oct 17, 2026
Implemented and merged into the
tinyagents-refactorbranch on the senamakel fork:8c08d9992e751bc6c5175ed769af68f05a475d6b)Closing this completed migration issue as requested.