airflow.providers.openai.operators.agent

Classes

OpenAIAgentSessionOperator

Run one turn in a fresh OpenAI Managed Agents session and return its session ID.

Module Contents

class airflow.providers.openai.operators.agent.OpenAIAgentSessionOperator(*, input, environment, agent_id=None, session_kwargs=None, conn_id=OpenAIHook.default_conn_name, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), poll_interval=10, timeout=3600, **kwargs)[source]

Bases: airflow.providers.common.compat.sdk.BaseOperator

Run one turn in a fresh OpenAI Managed Agents session and return its session ID.

The session is retained for downstream retrieval of items and artifacts. A retry creates a new session and can repeat external side effects.

Parameters:
  • input (str) – Initial user message. (templated)

  • environment (dict[str, Any]) – SDK environment configuration or template reference. (templated)

  • agent_id (str | None) – Saved agent ID. Alternatively supply agent.model in session_kwargs. (templated)

  • session_kwargs (dict[str, Any] | None) – Additional SDK session creation arguments, such as agent, vault_ids and metadata. Must not contain input, environment, agent_id or stream. (templated)

  • conn_id (str) – OpenAI connection ID. (templated)

  • deferrable (bool) – Release the worker while waiting for completion.

  • poll_interval (float) – Seconds between polls.

  • timeout (float) – Maximum seconds to wait for the initial turn. A shorter execution_timeout still applies and preempts the cancel-on-timeout path.

template_fields: collections.abc.Sequence[str] = ('input', 'environment', 'agent_id', 'session_kwargs', 'conn_id')[source]
template_fields_renderers[source]
input[source]
environment[source]
agent_id = None[source]
session_kwargs[source]
conn_id = 'openai_default'[source]
deferrable[source]
poll_interval = 10[source]
timeout = 3600[source]
session_id: str | None = None[source]
property hook: airflow.providers.openai.hooks.openai.OpenAIHook[source]

Return the connection’s OpenAI hook.

execute(context)[source]

Derive when creating an operator.

The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

execute_complete(context, event=None, session_id=None)[source]

Validate completion, record usage, and return the owned session ID.

on_kill()[source]

Request cancellation without deleting session history or artifacts.

Was this entry helpful?