aixplain.v1.modules.agent.agent_response_data
Agent response data.
This module contains the AgentResponseData class, which is used to encapsulate the input, output, and execution details of an agent's response, including intermediate steps and execution statistics.
Artifact Objects
@dataclass
class Artifact()
A user-facing deliverable produced during an agent run.
v1 mirror of aixplain.v2.agent.Artifact — same field names, same
semantics. Artifacts come from two sources:
source="tool_output"— media a tool generated (image/audio/video/page). Carries aurl, usually a presigned URL.source="workspace"— a file the agent wrote into its workspace. Carries inline UTF-8 text incontent(binary workspace files are skipped by the engine; there is no uploader yet).
Exactly one of url / content is populated.
Warnings:
url_expires_at is when the presigned URL dies, not the artifact.
Observed in the wild: a 24h window on a generated image URL. If you
persist artifact URLs (database, cache, sent email), re-host the bytes
before url_expires_at or the links will rot.
category and source are plain strings, not enums: the engine may add
new media categories before this SDK knows about them, and an unknown value
must pass through rather than raise.
Attributes:
idstr - Unique identifier of the artifact.namestr - URL basename, or workspace-relative path (outputs/report.csv).titleOptional[str] - Human-friendly title, when the engine set one.mime_typeOptional[str] - MIME type of the artifact content.categorystr -image/audio/video/page/document/code/data/archive/other, or any newer value the engine introduces.sourcestr -tool_outputorworkspace.tool_nameOptional[str] - Tool that produced it (tool_outputonly).urlOptional[str] - Presigned URL (tool_outputonly).url_expires_atOptional[str] - ISO-8601 expiry ofurl.contentOptional[str] - Inline UTF-8 text (workspaceonly).sha256Optional[str] - Content digest (workspaceonly).byte_sizeOptional[int] - Content size in bytes (workspaceonly).mentioned_in_answerbool - Whether the final answer cited the artifact.created_atstr - ISO-8601 creation timestamp.
from_dict
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "Artifact"
Create an Artifact from a snake_case or camelCase payload.
Unknown keys are ignored, and missing keys fall back to the field defaults. If a payload carries both spellings of a field, the one appearing last wins (matching the v2 decoder).
Arguments:
dataDict[str, Any] - The artifact payload.
Returns:
Artifact- A new instance populated with the payload data.
from_list
@classmethod
def from_list(cls, value: Any) -> List["Artifact"]
Decode an artifacts payload without ever raising.
Arguments:
valueAny - The rawartifactsvalue. Anything that is not a list (includingNone) yields an empty list.
Returns:
List[Artifact]- The decodable entries; junk entries are dropped.
to_dict
def to_dict() -> Dict[str, Any]
Convert the artifact to its camelCase wire representation.
Returns:
Dict[str, Any]: The artifact as a dictionary, matching the keys the v2 SDK emits.
get
def get(key: str, default: Optional[Any] = None) -> Any
Get an attribute value, dict-style, with a default.
Arguments:
keystr - The name of the attribute to get.defaultOptional[Any], optional - The value to return if the attribute is not found. Defaults to None.
Returns:
Any- The value of the attribute, or the default value if not found.
__getitem__
def __getitem__(key: str) -> Any
Get an attribute value using dictionary-style access.
Arguments:
keystr - The name of the attribute to get.
Returns:
Any- The value of the attribute, or None if not found.
AgentResponseData Objects
class AgentResponseData()
A container for agent execution response data.
This class encapsulates the input, output, and execution details of an agent's response, including intermediate steps and execution statistics.
Attributes:
inputOptional[Any] - The input provided to the agent.outputOptional[Any] - The final output from the agent.session_idstr - Identifier for the conversation session.intermediate_stepsList[Any] - List of steps taken during execution.stepsList[Any] - Reformatted list of steps with detailed execution info.execution_statsOptional[Dict[str, Any]] - Statistics about the execution.critiquesstr - Any critiques or feedback about the execution.artifactsList[Artifact] - Deliverables produced during the run. Always a list, empty when the run produced none or the backend predates artifact support.
__init__
def __init__(input: Optional[Any] = None,
output: Optional[Any] = None,
session_id: str = "",
intermediate_steps: Optional[List[Any]] = None,
steps: Optional[List[Any]] = None,
execution_stats: Optional[Dict[str, Any]] = None,
critiques: Optional[str] = None,
artifacts: Optional[List[Any]] = None)
Initialize a new AgentResponseData instance.
Arguments:
inputOptional[Any], optional - The input provided to the agent. Defaults to None.outputOptional[Any], optional - The final output from the agent. Defaults to None.session_idstr, optional - Identifier for the conversation session. Defaults to "".intermediate_stepsOptional[List[Any]], optional - List of steps taken during execution. Defaults to None.stepsOptional[List[Any]], optional - Reformatted list of steps with detailed execution info. Defaults to None.execution_statsOptional[Dict[str, Any]], optional - Statistics about the execution. Defaults to None.critiquesOptional[str], optional - Any critiques or feedback about the execution. Defaults to None.artifactsOptional[List[Any]], optional - Deliverables produced during the run, as raw payload dictionaries orArtifactinstances. Anything undecodable is dropped. Defaults to None, which yields an empty list.
from_dict
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "AgentResponseData"
Create an AgentResponseData instance from a dictionary.
Arguments:
dataDict[str, Any] - Dictionary containing response data with keys:- input: The input provided to the agent
- output: The final output from the agent
- session_id: Identifier for the conversation session
- intermediate_steps: List of steps taken during execution
- steps: Reformatted list of steps with detailed execution info
- executionStats: Statistics about the execution
- critiques: Any critiques or feedback
- artifacts: Deliverables produced during the run
Returns:
AgentResponseData- A new instance populated with the dictionary data.
to_dict
def to_dict() -> Dict[str, Any]
Convert the response data to a dictionary representation.
Returns:
Dict[str, Any]: A dictionary containing all response data with keys:
- input: The input provided to the agent
- output: The final output from the agent
- session_id: Identifier for the conversation session
- intermediate_steps: List of steps taken during execution
- steps: Reformatted list of steps with detailed execution info
- executionStats: Statistics about the execution
- execution_stats: Alias for executionStats
- critiques: Any critiques or feedback
- artifacts: Deliverables produced during the run
get
def get(key: str, default: Optional[Any] = None) -> Any
Get an attribute value using attribute-style access.
Arguments:
keystr - The name of the attribute to get.defaultOptional[Any], optional - The value to return if the attribute is not found. Defaults to None.
Returns:
Any- The value of the attribute, or the default value if not found.
__getitem__
def __getitem__(key: str) -> Any
Get an attribute value using dictionary-style access.
Arguments:
keystr - The name of the attribute to get.
Returns:
Any- The value of the attribute, or None if not found.
__setitem__
def __setitem__(key: str, value: Any) -> None
Set an attribute value using dictionary-style access.
Arguments:
keystr - The name of the attribute to set.valueAny - The value to assign to the attribute.
Raises:
KeyError- If the key is not a valid attribute of the class.
__repr__
def __repr__() -> str
Return a string representation of the response data.
Returns:
str- A string showing all attributes and their values in a readable format.
__contains__
def __contains__(key: Text) -> bool
Check if an attribute exists using 'in' operator.
Arguments:
keyText - The name of the attribute to check.
Returns:
bool- True if the attribute exists and is accessible, False otherwise.