Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

4.0 KB
Raw Blame

generation

Image and video generation agent tools over generators a host supplies. The TinyHumans host builds OpenRouter generators behind its backend proxy (openhuman-tinyhumans, integrations/media). The work is split across three layers, each with a different owner:

  • TinyInference (tinyinference-image / tinyinference-video, reached through tinyagents_harness) owns the wire contract, the reference and output-shape standards, the submit-poll-download job loop for video, and the rule that a billed call always returns media or an error, never an empty success.
  • TinyAgents (tinyagents_harness::media) owns the tools themselves: argument parsing, artifact persistence into the workspace, and result wording.
  • This module owns the MediaGenerators pair (provider.rs), plus the tool names, descriptions, and local-reference policy (tools.rs). Endpoint, credential, egress, privacy and budget gates belong to the host that builds the generators.

Key files

File Role
provider.rs MediaGenerators { image, video } and GeneratorRouter: the pair the tools run over, with an optional router that rebuilds them around a turn's chat so egress disclosures reach it. The core ships no generators.
tools.rs media_tools_for_config: registers media_generate_image, media_generate_video, and media_list_models as Tool implementations over host-supplied generators. Also defines reference_policy, which restricts local reference files (for image edits or video first/last frames) to the action directory or workspace directory.
artifact_tool.rs MediaArtifactTool: wraps a generation tool so every file it saves is also tracked as an OpenHuman artifact, through the same Production flow (reserve, write, complete) the document and presentation tools use. Runs the inner tool unchanged, then files each reported output and stamps an artifact_id (or artifact_error) onto its entry.
progress.rs Progress for a long generation call: a heartbeat every 15s through ToolRunContext::report_progress while the inner tool runs, carrying the video job state the WaitPolicy::progress observer records on each poll. The harness emits these as AgentEvent::ToolProgressDetail, which the host publishes on the web channel as tool_progress; the chat UI does not render it yet.
mod.rs Re-exports: MediaArtifactTool, MediaGenerators, GeneratorRouter, media_tools_for_config, media_tools_from, MediaReferenceAllowlist, MediaListModelsTool, and the three tool-name constants.

Key types

  • MediaGenerators { image: Arc<dyn ImageGenerator>, video: Arc<dyn VideoGenerator> }, the pair of generators for one process.
  • MediaArtifactTool<T: Tool>, the artifact-tracking wrapper described above.
  • MediaListModelsTool, a read-only tool that lists the image and video models the current generators can run, with an optional substring filter.

How it fits

build_media_tools is called from wherever the tool registry assembles the agent's tool list; it returns an empty list rather than erroring when no hosted media provider is registered, so a library host with no TinyHumans connection simply has no media tools rather than a broken one. TinyAgents stores generated bytes in its media blob store, and MediaArtifactTool copies each one into the visible files folder (~/OpenHuman/projects/Files, metadata in the workspace's artifacts/<id>/). JSON and Markdown results point at the filed path so it can be reused as a later media reference and shown as a card in the chat UI. Ready image and video paths remain reusable after a session rebuild; failed artifacts are excluded. Billing and margin stay backend-side: this module never charges directly, it only refuses to submit when crate::integrations::client::budget_gate reports the account's managed credits are exhausted.

Where to look next

See ../README.md for the media domain overview.