Skip to content

[tiny-modules] tinyagents: move turn policy, outcome, deadline, stop, error and cost accounting into tinyagents-harness #7600

Closed

Description

@senamakel

Parent: #7540

Context

Turn-level run policy, outcome classification, finalisation, wall-clock deadline, stop reasons, agent-loop error types and per-call cost accounting are generic harness concerns. The harness already has terminal.rs, cost/ and turn_clock. The host keeps only the product projection of errors, progress and cost.

What moves

Path LOC Class
agent/tinyagents/turn_policy.rs 499 Split: generic run policy up
agent/tinyagents/turn_outcome.rs 173 Split
agent/tinyagents/turn_run_error.rs 91 Split
agent/tinyagents/turn_run_finalize.rs 342 Split: finalisation up; product error and progress projection stays
agent/tinyagents/response_shape.rs 410 Moves: per-turn response format and output cap; drop the task-local (Task 4)
agent/turn_deadline.rs 151 Moves (harness turn_clock)
agent/turn_stop.rs 165 Moves (harness terminal.rs)
agent/error.rs 249 Moves (host-free agent-loop errors)
agent/cost.rs 185 Moves partly (harness cost/); pricing lookup stays
agent/tool_policy.rs 141 Moves: duplicates harness library/tool_policy.rs

What stays in OpenHuman

Product projection: AgentProgress and the cost UI, Sentry classification, OpenHuman pricing table lookup, failure_copy.

Upstream target

  • tinyhumansai/tinyagents: tinyagents-harness (terminal.rs, cost/, middleware/library/{turn_clock,tool_policy}).
  • Plan Task 4 (response_shape task-local) and Task 8.

Host adapter after the move

The host maps harness TurnOutcome/StopReason/CostRecord to RPC and progress events in one projection module.

Acceptance criteria

  • Upstream PR merged in the owning repo first, then the gitlink bumped here to that merged commit. This is a Cargo library (kernel), so there is no cdylib release; CI builds the merged upstream commit.
  • Tests move with the code; host keeps only composition/adapter tests.
  • Old core code and its *_tests.rs deleted in the same PR — no re-export shims, no pub use aliases.
  • Matching entries removed from scripts/ci/agent-runtime-boundary-baseline.json (where applicable) and the ratchet still passes.
  • pnpm rust:layout, cargo check --manifest-path Cargo.toml, cargo check --manifest-path crates/openhuman-app/Cargo.toml green.
  • Every behaviour change ships with a regression test (failing before, passing after); pnpm debug rust <filter> for the affected suites.
  • The rg 'task_local!' agent/tinyagents/response_shape.rs hit is gone.
  • Cost totals for a scripted multi-call turn on the mock backend are unchanged (regression test).

Depends on

Activity

  1. added
    subtaskSubtask of a larger tracked effort.
    refactorStructural code change without a primary behavior change.
    rust-coreCore Rust runtime in src/: CLI, core_server, shared infrastructure.
    harnessAgent harness / orchestration
    on Oct 12, 2026
  2. added
    priority: p3Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.
    on Oct 13, 2026
  3. tinysweeper commented on Oct 13, 2026

    @tinysweeper

    Refactoring task in the tiny-modules series (parent #7540): move generic turn policy, outcome, deadline, stop, error, and cost accounting from OpenHuman's agent/tinyagents into the tinyagents-harness upstream crate, keeping only the host product projection and adapter.

    Labelled priority: p3.

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

    @senamakel
    MemberAuthor

    Module side (partial) merged: tinyhumansai/tinyagents#436 (merge e1f8e93b5fe79dce7494a271d0065453fdfae4ce on tinyagents main). Pin vendor/tinyagents to that commit; host-side deletion/adaptation still to do. Unported items are listed in the PR body.

  6. senamakel commented on Oct 13, 2026

    @senamakel
    MemberAuthor

    Module side merged: tinyhumansai/tinyagents#438 (merge commit a7c9d23cae087b305dbaece7d44e01d1161235d3 on tinyagents main). No release (library-gitlink): pin vendor/tinyagents to that commit. Host-side deletion/adaptation for this leaf is still to do; see the PR body for the per-leaf summary.

  7. senamakel commented on Oct 14, 2026

    @senamakel
    MemberAuthor

    Partially landed in #7773 (module: tinyhumansai/tinyagents#438). Done: turn_run_error delegates to harness. Remaining: turn_policy, turn_outcome, turn_run_finalize, response_shape, agent/tool_policy, projection module, cost regression test.

  8. senamakel commented on Oct 14, 2026

    @senamakel
    MemberAuthor

    Module side merged: tinyagents#445 (merge a2bf2b0d). Pin vendor/tinyagents to a2bf2b0df6b70fbeed3bd171ff8f54521f94e496 (main). Host-side cutover/deletions still pending in OpenHuman.

  9. senamakel commented on Oct 14, 2026

    @senamakel
    MemberAuthor

    Merged in #7787; module PR tinyhumansai/tinyagents#445. Deleted agent/error.rs, turn_stop.rs, response_shape (task-local gone), generic halves of turn_policy/outcome/finalize, cost types. Remaining: agent/turn_deadline.rs (close_budget), agent/tool_policy.rs migration to ToolCallPolicy (public seam), unify host TurnCost (needs tinyagents pricing injection).

  10. senamakel commented on Oct 14, 2026

    @senamakel
    MemberAuthor

    Module slice merged: tinyhumansai/tinyagents#448 (merge c7bce17370b9d7425fec679cb331a93a5e362033 on tinyagents main) adds TurnDeadline::close_budget + CLOSE_RESERVE with a test. Host cutover NOT landed: any tinyagents main commit containing it also contains #446/#447 (artifacts offload moved to a tinystoragedrivers BlobStore: ArtifactOffload::new(blobs,..), with_render_root removed), so bumping vendor/tinyagents breaks agent/harness/artifact_offload and subagent_host/ops/runner.rs until the host supplies a BlobStore and materialises/exposes artifacts to file_read (storage work). Remaining after that pin bump: replace turn_deadline::close_budget(&d, now) in session_host/driver.rs with d.close_budget(now) and delete agent/turn_deadline.rs (keep the env + task-local scope in a host-side file, e.g. session_host/turn_backstop.rs); migrate agent/tool_policy.rs to a harness ToolCallPolicy<Ctx> (does not exist in tinyagents yet, tinyagents change first, public seam); unify host TurnCost with harness one (needs tinyagents pricing injection); scripted-turn cost regression test.

  11. added a commit that references this issue on Oct 14, 2026
  12. senamakel commented on Oct 14, 2026

    @senamakel
    MemberAuthor

    Slice landed: openhuman#7798 (a6462c1) with tinyagents#450 (c7a763b6); close_budget was tinyagents#448.

    Done:

    • vendor/tinyagents pinned to main c7a763b6. The host adopted the [Bug][Autocomplete][macOS] Repeated not authorised Apple Events errors (-1743) #446/[Perf/Cost] Optimize prompt payloads and stop repeating full context each turn #447 blob-store artifact API: ArtifactOffload runs over the acting tenant's blob store and the stored body is materialised under the parent's action root so the pointer path still opens with file_read; the workspace-internal guard now checks the materialised target.
    • agent/turn_deadline.rs deleted; d.close_budget(now) from the harness; env override and task-local in session_host/turn_backstop.rs.
    • agent/tool_policy.rs deleted. Correction to the earlier note: ToolCallPolicy<Ctx> and PolicyDecision already existed in the harness (middleware/library/policy_gate.rs), so no upstream change was needed; the host uses them directly.
    • Host TurnCost deleted. The harness TurnCost now prices recorded responses through an injected lookup (TurnCost::with_pricing, impl StopHookMetrics, StopHookMiddleware::with_metrics_seed). The scripted four-call cost regression test now runs through that path with unchanged totals.

    Remaining on this leaf (not started):

    • Splits of tinyagents/turn_policy.rs, turn_outcome.rs, turn_run_error.rs, turn_run_finalize.rs.
    • response_shape.rs move and its task_local! (Task 4).
    • agent/turn_stop.rs into harness terminal.rs; agent/error.rs host-free errors; agent/cost.rs call_cost helpers (lookup stays).
    • Boundary baseline: no entries mapped to the removed files; 2 vendor entries (EarlyExit re-export in tinyagents-runtime, ExposureProbe alias in harness tool tests) arrived with the [Bug] Release script never bumps root Cargo.toml — core binary reports stale version since v0.49.17 #449 pin and should be fixed upstream, then dropped.
  13. added a commit that references this issue on Oct 14, 2026
  14. senamakel commented on Oct 14, 2026

    @senamakel
    MemberAuthor

    Closed by openhuman#7812 with tinyagents#455 (616fc23c). Last items: EarlyExit re-export and ExposureProbe alias fixed upstream, baseline entries dropped. Everything else on the list landed earlier in #7773, #7787, #7798.

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

    harnessAgent harness / orchestrationpriority: p3Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.refactorStructural code change without a primary behavior change.rust-coreCore Rust runtime in src/: CLI, core_server, shared infrastructure.subtaskSubtask of a larger tracked effort.

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions