datarobot_genai.dragent.frontends.session
session
DRAgentUserManager
Bases: UserManager
Add DataRobot signed auth-context resolution to NAT's standard identity extractors.
NAT 1.6 replaced the extensible context-based user_id resolution with
UserManager.extract_user_from_connection() (#1775), which only supports
standard auth (Bearer JWT, cookies, API key). DataRobot passes user identity
via X-DataRobot-Authorization-Context (signed app-context JWT), which the
vanilla extractor does not understand. This subclass handles that header
first, then delegates to super().extract_user_from_connection() so
standard auth still works.
Source code in datarobot_genai/dragent/frontends/session.py
DRAgentAGUISessionManager
Bases: SessionManager
Source code in datarobot_genai/dragent/frontends/session.py
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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
session
async
session(user_id: str | None = None, http_connection: HTTPConnection | None = None, user_message_id: str | None = None, conversation_id: str | None = None, user_input_callback: Callable[[InteractionPrompt], Awaitable[HumanResponse]] | None = None, user_authentication_callback: Callable[[AuthProviderBaseConfig, AuthFlowType], Awaitable[AuthenticatedContext | None]] | None = None) -> AsyncIterator[Session]
Bridge A2A preset, resolve DR headers, default for per-user, and inject A2A headers.
NAT 1.6+ assigns self._context_state.user_id from the explicit user_id
argument only. The A2A adapter calls session() with no arguments; our
executor sets context_id on the context var first, but the parent
session() would overwrite it with None. Copy any preset non-empty
value into user_id before delegating so per-user workflows work without
a Bearer JWT (local dev / message-only A2A).
Additionally, A2A HTTP request headers stored in the module-level
_a2a_headers ContextVar by :class:_PerUserCompatibleAgentExecutor are
injected into ContextState._metadata.
Source code in datarobot_genai/dragent/frontends/session.py
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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
get_workflow_input_schema
get_workflow_streaming_output_schema
headers_from_a2a_state
Extract normalised HTTP headers from an A2A server or call context state dict.
Source code in datarobot_genai/dragent/frontends/session.py
resolve_identity_from_headers
resolve_identity_from_headers(headers: dict[str, str] | None, *, on_invalid_auth_context: Literal['error', 'none'] = 'error') -> str | None
Extract gateway-validated user identity from forwarded HTTP headers.
Resolution order (first match wins):
X-DataRobot-Authorization-Context-- signed JWT forwarded by components in the agent application template. Decoded via :data:_auth_handlerand hashed throughUserInfo._from_session_cookieto produce the same UUID5 workflow key as the AG-UI path. When this header is present but validation fails, behaviour depends on on_invalid_auth_context:"error"raises :class:~a2a.utils.errors.ServerErrorwith :class:`~a2a.types.InvalidParamsError(no fall-through to other headers orcontext_id);"none"returnsNone``.X-DataRobot-User-Id-- raw DataRobot user ID injected by the API gateway, tied to the API-key owner. Used only when the auth-context header is absent. Same_from_session_cookietransform is applied for key-format consistency.None-- no gateway-provided identity (local dev).
Returns None when headers are absent or contain no recognised
identity header.