datarobot_genai.core.agents.base
base
BaseAgent
Bases: Generic[TTool], ABC
BaseAgent centralizes common initialization for agent templates.
Fields
- api_key: DataRobot API token
- api_base: Endpoint for DataRobot, normalized for LLM Gateway usage
- llm: Framework-specific LLM client (constructed outside the agent and passed in)
- model: Optional model identifier string (e.g. LiteLLM / deployment model name)
- timeout: Request timeout
- verbose: Verbosity flag
- forwarded_headers: Forwarded headers for the agent
- max_history_messages: Maximum number of prior messages to include in chat history
Source code in datarobot_genai/core/agents/base.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
tools
property
Return the list of tools available to this agent.
Subclasses can use this to wire tools into the agent.
max_history_messages
property
Maximum number of prior messages to include in chat history.
Defaults to DATAROBOT_GENAI_MAX_HISTORY_MESSAGES env var (read at
call time). Subclasses can override via the constructor parameter or
by overriding this property.
forwarded_headers
property
Return the forwarded headers for this agent.
invoke_single_message
async
Invoke the agent without chat history with a single user message.
Parameters
user_message: str The user message to invoke the agent with.
Returns
InvokeReturn
Same async stream as :meth:invoke for a fresh run with a single user turn.
Source code in datarobot_genai/core/agents/base.py
build_history_summary
Instance helper to summarize prior turns as plain-text transcript.
Subclasses can override max_history_messages to control how many
prior messages are included. This is primarily intended for exposing a
chat_history variable in prompts across different agent types.
Source code in datarobot_genai/core/agents/base.py
history_messages
Prior turns as structured dicts (role/content + tool_calls/tool_call_id).
Same history selection and max_history_messages truncation as
:meth:build_history_summary, but preserves structured tool-call metadata so
framework adapters can reconstruct native message history instead of
flattening to text. See datarobot_genai.langgraph.history and
datarobot_genai.llama_index.history.
Tool-call/result turns left unpaired by max_history truncation are dropped
so the reconstructed message sequence stays valid for the model.
Source code in datarobot_genai/core/agents/base.py
create_pipeline_interactions_from_events
classmethod
Create a simple MultiTurnSample from a list of generic events/messages.
Source code in datarobot_genai/core/agents/base.py
extract_streaming_memory_context
Return streaming_memory_agent context to prepend to a user prompt, or None.
Source code in datarobot_genai/core/agents/base.py
prepend_streaming_memory_to_prompt
Prepend streaming_memory_agent context to a processed user prompt.
Source code in datarobot_genai/core/agents/base.py
extract_user_prompt_content
Extract the last user message content from input.
Source code in datarobot_genai/core/agents/base.py
make_system_prompt
Build a system prompt with optional prefix and suffix.
Parameters
suffix : str, default ""
Text appended after the prefix. If non-empty, it is placed on a new line.
prefix : str | None, keyword-only, default None
Custom prefix text. When None, a default collaborative assistant
instruction is used.
Returns
str The composed system prompt string.
Source code in datarobot_genai/core/agents/base.py
default_usage_metrics
Return a metrics dict with required keys for OpenAI-compatible responses.