Renderer: Agent Output Renderer (UI-agnostic contract)

RendererR Documentation

Agent Output Renderer (UI-agnostic contract)

Description

Renderer is the canonical, UI-agnostic contract for presenting an agent's streaming output. The agent runtime (driven by stream_text() / run_agent_runtime()) emits agent-output events purely through these semantic methods, so the same agent-output logic can be rendered in a terminal (the built-in cli backend, create_stream_renderer()), a web app (e.g. aisdk.shiny), a test/replay harness (create_capture_renderer()), or any custom UI – by implementing this interface.

The agent-output event model captures what an agent does as it responds:

  • text – streamed assistant text, delivered incrementally via process_chunk(text, done); the final call usually has text = NULL and done = TRUE.

  • thinking – a reasoning stream bracketed by start_thinking() and stop_thinking().

  • tools – tool execution: render_tool_start(name, arguments) followed by render_tool_result(name, result, success, raw_result).

  • steps – multi-step ReAct loop boundaries, reset_for_new_step().

Every method is a no-op in the base class, so the base class is itself a usable null renderer and a subclass need only override the events it cares about.

Methods

Public methods


Method process_chunk()

Render a chunk of streamed assistant text.

Usage
Renderer$process_chunk(text, done = FALSE)
Arguments
text

A character chunk, or NULL on the final (done) call.

done

TRUE when the current text segment is complete.

Returns

Invisibly NULL.


Method start_thinking()

Signal the start of a thinking/reasoning stream.

Usage
Renderer$start_thinking()
Returns

Invisibly NULL.


Method stop_thinking()

Signal the end of a thinking/reasoning stream.

Usage
Renderer$stop_thinking()
Returns

Invisibly NULL.


Method render_tool_start()

Render the start of a tool call.

Usage
Renderer$render_tool_start(name, arguments)
Arguments
name

Tool name.

arguments

Tool arguments (a list).

Returns

Invisibly NULL.


Method render_tool_result()

Render a tool result.

Usage
Renderer$render_tool_result(name, result, success = TRUE, raw_result = NULL)
Arguments
name

Tool name.

result

The display result.

success

Whether the tool call succeeded.

raw_result

The raw (unformatted) result.

Returns

Invisibly NULL.


Method reset_for_new_step()

Reset transient render state at a new ReAct step boundary.

Usage
Renderer$reset_for_new_step()
Returns

Invisibly NULL.


Method clone()

The objects of this class are cloneable with this method.

Usage
Renderer$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


aisdk documentation built on May 29, 2026, 9:07 a.m.