module Riffer::Agent::Run

Riffer::Agent::Run is the generation loop. A pure module of functions over an agent β€” Agent owns every per-call value (provider, model, tools, tool runtime, structured output, session, context); Run just orchestrates.

Tools and user code see the agent’s context (a Riffer::Agent::Context) unchanged through the loop, so downstream tool runtimes can read caller-provided keys via context[:agent] / context.dig(:key), or the framework built-ins via context.skills. Cumulative token usage is updated into agent.context.token_usage as the loop progresses.

Riffer::Agent::Run.generate(agent: my_agent, prompt: "Hello")
Riffer::Agent::Run.stream(agent: my_agent, prompt: "Hello")