Agent Base
The base Agent class provides the core interface and functionality that all rLLM agents inherit from.
rllm.agents.agent
Trajectory
dataclass
Source code in rllm/agents/agent.py
from_dict
classmethod
Create Trajectory from dictionary, properly deserializing Step objects.
Source code in rllm/agents/agent.py
is_cumulative
Returns True if for every step after the first, its chat_completions is an exact superset of the previous step's chat_completions (i.e., the previous chat_completions is a prefix).
Source code in rllm/agents/agent.py
Episode
dataclass
Source code in rllm/agents/agent.py
from_dict
classmethod
Create Episode from dictionary, properly deserializing Trajectory objects.
Source code in rllm/agents/agent.py
BaseAgent
Bases: ABC
Source code in rllm/agents/agent.py
chat_completions
property
Converts agent's internal state into a list of OAI chat completions.
trajectory
property
Converts agent's internal state into a Trajectory object.
update_from_env
Updates the agent's internal state after an environment step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observation
|
Any
|
The observation after stepping through environment. |
required |
reward
|
float
|
The reward received after taking the action. |
required |
done
|
bool
|
Whether the episode has ended due to termination. |
required |
info
|
dict
|
Additional metadata from the environment. |
required |
Source code in rllm/agents/agent.py
update_from_model
Updates the agent's internal state after the model generates a response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
str
|
The response from the model. |
required |
Returns:
| Type | Description |
|---|---|
Action
|
None |
Source code in rllm/agents/agent.py
reset
abstractmethod
Resets the agent's internal state, typically called at the beginning of a new episode.
This function should clear any stored history or state information necessary for a fresh interaction.
Returns:
| Type | Description |
|---|---|
|
None |
Source code in rllm/agents/agent.py
get_current_state
Returns the agent's current state as a dictionary.
This method provides access to the agent's internal state at the current step, which can be useful for debugging, logging, or state management.
Returns:
| Name | Type | Description |
|---|---|---|
Step |
Step | None
|
The agent's current state. |