datarobot_genai.dragent.inline
inline
In-process dragent execution for use as a DRUM alternative in run_agent.py.
Mirrors the entry shape of datarobot_drum's execute_drum_inline so the
host script can route between DRUM and dragent with a single env-var-gated
branch. The function always returns a single aggregated OpenAI
ChatCompletion; the request's stream flag is ignored because the
agentic playground only renders the final assistant message.
execute_dragent_inline_async
async
execute_dragent_inline_async(chat_completion: CompletionCreateParamsBase, custom_model_dir: Path, *, config_file: Path | None = None) -> ChatCompletion
Execute a dragent workflow in-process and return the final OpenAI ChatCompletion.
The function delegates aggregation to NAT: runner.result(to_type=ChatResponse)
is the same call the dragent FastAPI route uses for non-streaming
/v1/chat/completions requests. NAT workflows already declare how to
produce a single response — per_user_tool_calling_agent registers
single_output_type=ChatResponse natively, and dragent-native agents
(base, langgraph, crewai, llamaindex) declare
Streaming(convert=aggregate_dragent_event_responses) so NAT collapses
their stream and then chains the registered global converter
DRAgentEventResponse → ChatResponseChunk through to ChatResponse.
The OpenAI ChatCompletion is then a structural re-validation of NAT's
OpenAI-compatible ChatResponse.
Parameters
chat_completion
OpenAI Chat Completions create-params dict (stream is ignored).
custom_model_dir
Directory containing the agent code. workflow.yaml is loaded from
here when config_file is not supplied.
config_file
Optional explicit override of the workflow YAML path.
Source code in datarobot_genai/dragent/inline.py
execute_dragent_inline
execute_dragent_inline(chat_completion: CompletionCreateParamsBase, custom_model_dir: Path, *, config_file: Path | None = None) -> ChatCompletion
Run :func:execute_dragent_inline_async synchronously for run_agent.py.
Sync entry point used by datarobot-user-models's run_agent.py when the
dragent inline path is enabled. The host process may already have an asyncio
loop running on the current thread (for example when run_agent_procedure
is invoked from an ipykernel driven agentic notebook) without exposing
that loop to this call site; in that case asyncio.run cannot be used here
and the coroutine is executed in a worker thread with its own event loop.