Skip to content

tinyagents-hooks: new crate holding every hook type #470

Closed

Description

@senamakel

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-process ToolHook<Ctx> (before_tool_decision / before_tool / after_tool / after_tool_context), ToolHookContext, ToolHooksMiddleware<Ctx>, a HookIdentity extractor trait (session_id, agent_id, cwd) and sanitize_tool_output.
    • One ToolHookDecision type, unified with the command-hook allow / deny / ask / updated_input / additional_context vocabulary.
    • Source: OpenHuman agent/hooks.rs (383 lines) and agent/tinyagents/middleware/embedder_hooks.rs (258).
  • command/: move tinyagents-runtime/src/command_hooks/ here. It is self-contained and imports only super::.
    • HookEngine implements ToolHook directly.
    • Absorb the derived-event mapping from OpenHuman src/hooks/bridge.rs (373) and the lifecycle entry points session_started, prompt_submitted, pre_compact and subagent_* from src/hooks/ops.rs (263).
  • stop/: move harness/src/middleware/library/stop_hooks/ and stop_latch.rs here, along with impl StopHookMetrics for TurnCost.
    • Add a stock BudgetStopHook (OpenHuman agent/stop_hooks.rs) and GoalBudgetStopHook (OpenHuman agent/goals/runtime.rs, taking Arc<dyn Store>, behind a goals feature).
    • Add StopHookMiddleware::with_halt_summary(slot) (OpenHuman agent/tinyagents/stop_hooks.rs).
  • lifecycle/: move harness/src/middleware/library/lifecycle_hooks/ here.
  • turn/: post-turn hooks folded into LearningSink.
    • Extend TurnSummary with per-tool outcome records: name, args digest, success, classified failure, duration.
    • Add parallel fire_* dispatch.
    • This replaces OpenHuman's PostTurnHook/TurnContext.
  • scope.rs: HookScope, the per-turn tool, learning and stop hook lists (OpenHuman agent/hooks_scope.rs). Also add FnSessionHooks<C>, a closure-backed SessionHooks (OpenHuman agent/session_host/hooks.rs).

Compat

  • tinyagents-runtime re-exports command_hooks for one release.
  • Moving the harness middleware::StopHook paths is a breaking change: bump the minor version, add a CHANGELOG entry, and add docs/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.

Activity

  1. added
    enhancementNew feature or request
    rustPull requests that update rust code
    on Oct 16, 2026
  2. added
    priority: p3Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.
    on Oct 16, 2026
  3. tinysweeper commented on Oct 16, 2026

    @tinysweeper

    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.

  4. added theissue type on Oct 16, 2026
  5. senamakel commented on Oct 17, 2026

    @senamakel
    MemberAuthor

    Implemented and merged into the tinyagents-refactor branch on the senamakel fork:

    Closing this completed migration issue as requested.

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

    enhancementNew feature or requestpriority: p3Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.rustPull requests that update rust code

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions