WorkflowAgent: WorkflowAgent

WorkflowAgentR Documentation

WorkflowAgent

Description

A lightweight, Agent-compatible wrapper around a 'Workflow'. Created via Workflow$as_agent().

'WorkflowAgent' exposes the same interface that 'LeadAgent' expects from any agent (name, instruction, agent_id, $invoke()), so it can be:

  • Registered with LeadAgent$register_agents().

  • Used as a Station handler inside another 'Workflow'.

Do not instantiate 'WorkflowAgent' directly - use Workflow$as_agent().

Public fields

name

Agent name (visible to 'LeadAgent' for task matching).

instruction

System instruction describing the agent's role.

agent_id

Unique identifier (UUID).

workflow

The underlying 'Workflow' object.

messages

Conversation history as a list of list(role, content) entries.

Methods

Public methods


Method new()

Create a new 'WorkflowAgent'. Prefer Workflow$as_agent().

Usage
WorkflowAgent$new(name, instruction, workflow)
Arguments
name

'[character(1)]' Agent name.

instruction

'[character(1)]' Instruction / system prompt.

workflow

A 'Workflow' object.


Method invoke()

Run the underlying workflow with 'prompt' as input.

Not compatible with a wrapped 'Workflow' whose hitl_mode is '"pause"': a 'WorkflowAgent' is invoked synchronously from a 'Workflow' Station or a 'LeadAgent' step, both of which expect a single character result back, not a 'mini007_pending' object to resume later. Use hitl_mode = "console" (the default), or drive the wrapped workflow directly with $workflow$run() / $resume() if you need pause/resume HITL.

Usage
WorkflowAgent$invoke(prompt, stream = FALSE, on_event = NULL)
Arguments
prompt

'[character(1)]' The user prompt / input payload.

stream

‘[logical(1)]' Whether to stream the wrapped workflow’s progress (see Workflow$run()).

on_event

'[function | NULL]' Callback receiving each 'mini007_event' emitted by the wrapped workflow and its Agents. Supplying it implies stream = TRUE.

Returns

'[character(1)]' The final output of the workflow.


Method as_tool()

Wraps the workflow in an ellmer tool, so that an agent can run it. See Agent$as_tool(): the tool's ‘request' is the workflow’s input, and it returns the workflow's output.

Usage
WorkflowAgent$as_tool(description = NULL, name = NULL, fresh = FALSE)
Arguments
description

'[character(1) | NULL]' What the workflow does. Defaults to a description made from the name and instruction.

name

'[character(1) | NULL]' The tool name. Defaults to the agent's name.

fresh

'[logical(1)]' If 'TRUE', $messages is cleared before each run.

Returns

An ellmer tool.


Method reset_conversation_history()

Clear the conversation history stored in $messages.

Usage
WorkflowAgent$reset_conversation_history()
Returns

Invisibly returns 'self'.


mini007 documentation built on Dec. 3, 2026, 5:10 p.m.