yera.models.workspace

Workspace module for managing conversation state and message history.

This module provides the Workspace class which serves as a container for managing message sequences and variables in an app execution context.

Symbols

class Workspace — Manages message history and variable state for app execution.

Workspace

Manages message history and variable state for app execution.

The Workspace maintains a list of messages exchanged during app execution and provides a dictionary for storing arbitrary variables and context needed during execution. It provides convenience methods for adding messages of different roles (user, system, assistant).

Attributes

messages
type: list[Message]

A list of Message objects representing the conversation history.

variables
type: dict

A dictionary for storing execution context and variables.

Methods

__init__ — Initialize an empty workspace with a distinct cache identity.
wire_messages — Get messages in the workspace not tagged as control flow.
add_user_message — Add a user message to the workspace.
add_sys_message — Add a system message to the workspace.
add_assistant_message — Add an assistant message to the workspace.
add_tool_call_message — Add a tool-call message to the workspace.
add_tool_result_message — Add a tool-result message to the workspace.

Workspace.__init__

__init__()

Initialize an empty workspace with a distinct cache identity.

Workspace.wire_messages

wire_messages() → list[Message]

Get messages in the workspace not tagged as control flow.

Returns

type: list[Message]

Messages eligible to be sent to a model provider.

Workspace.add_user_message

add_user_message(
    content: str,
) → None

Add a user message to the workspace.

Parameters

content
type: str

User-authored message content.

Workspace.add_sys_message

add_sys_message(
    content: str,
) → None

Add a system message to the workspace.

Parameters

content
type: str

System instruction content.

Workspace.add_assistant_message

add_assistant_message(
    content: str,
    thinking: str | None = None,
    on_wire: bool = True,
    provider_data: list[dict[str, object]] | None = None,
) → None

Add an assistant message to the workspace.

Parameters

content
type: str

Assistant response content.

thinking
type: str | None = None

Optional reasoning content retained with the message.

on_wire
type: bool = True

Whether the message should be sent in later requests.

provider_data
type: list[dict[str, object]] | None = None

Optional provider-specific response metadata.

Workspace.add_tool_call_message

add_tool_call_message(
    content: str,
    tool_id: str,
    call_id: str,
    tool_schema: dict,
    provider_data: list[dict[str, object]] | None = None,
) → None

Add a tool-call message to the workspace.

Parameters

content
type: str

Serialized tool-call content.

tool_id
type: str

Stable tool identifier.

call_id
type: str

Provider-issued call identifier.

tool_schema
type: dict

Schema describing the invoked tool.

provider_data
type: list[dict[str, object]] | None = None

Optional provider-specific call metadata.

Workspace.add_tool_result_message

add_tool_result_message(
    content: str,
    tool_id: str,
    call_id: str,
    tool_schema: dict,
) → None

Add a tool-result message to the workspace.

Parameters

content
type: str

Serialized tool result.

tool_id
type: str

Stable tool identifier.

call_id
type: str

Provider-issued call identifier.

tool_schema
type: dict

Schema describing the invoked tool.