Skip to content

feat: Add support for OpenAI Agents SDK #637

Description

@NiveditJain

Allow developers to use the OpenAI Agents SDK with Exosphere as the underlying reliability and orchestration platform.

# Goal: familiar OpenAI patterns, Exosphere reliabilityfromexospherehost.openaiimportagentsagent=agents.Agent(
name="research-assistant",
instructions="You help with research tasks",
tools=[web_search, file_reader]
)
# Runs on Exosphere with retries, state persistence, observabilityresult=awaitagents.run(agent, "Find recent papers on LLM agents")

Why This Matters

Without ExosphereWith Exosphere
Agent crashes = lost progressState persisted, resumable
No retry logicConfigurable retry policies
No observabilityFull execution trace in dashboard
Single machineDistributed across workers
Manual orchestrationGraph-based multi-agent workflows

OpenAI Agents SDK Overview

The OpenAI Agents SDK provides:

  • Agents: LLM + instructions + tools
  • Tools: Functions the agent can call
  • Handoffs: Agent-to-agent delegation
  • Guardrails: Input/output validation
  • Tracing: Execution visibility
# Standard OpenAI Agents SDK usagefromagentsimportAgent, Runneragent=Agent(
name="assistant",
instructions="You are helpful",
tools=[my_tool]
)
result=Runner.run_sync(agent, "Hello")

Proposed Integration

Approach: Wrap OpenAI SDK, Execute on Exosphere

flowchart TB
subgraph "Developer Code"
DEV[from exospherehost.openai import agents]
end
subgraph "exospherehost.openai"
WRAP[Thin wrapper over OpenAI SDK]
end
subgraph "Exosphere Runtime"
NODE[AgentNode executes agent]
SM[State Manager tracks progress]
end
DEV --> WRAP
WRAP --> NODE
NODE --> SM
Loading

Key Design Decisions

  1. Minimal wrapper: Don't reimplement OpenAI SDK, wrap it
  2. Transparent to developers: Same API they already know
  3. Opt-in reliability: Easy to add retries, persistence
  4. Graph integration: Agents as nodes in larger workflows

Prototype Scope

In Scope

  • exospherehost.openai.agents module
  • Wrap Agent and Runner classes
  • Execute agent runs as Exosphere states
  • Basic retry support
  • Execution tracking in dashboard

Out of Scope (Future)

  • Multi-agent handoffs as graph edges
  • Streaming responses through Exosphere
  • Custom tool execution as separate nodes
  • Guardrails integration

API Design (Draft)

Simple Usage

fromexospherehost.openaiimportagents# Define agent (same as OpenAI SDK)assistant=agents.Agent(
name="assistant",
instructions="You help users with questions",
model="gpt-4o"
)
# Run with Exosphere reliabilityresult=awaitagents.run(
assistant, "What is the capital of France?",
retry_policy={"max_retries": 3, "strategy": "EXPONENTIAL"}
)
print(result.output)

As Part of a Graph

fromexospherehostimportBaseNodefromexospherehost.openaiimportagentsclassResearchAgent(BaseNode):
classInputs(BaseModel):
query: strclassOutputs(BaseModel):
findings: strasyncdefexecute(self, inputs):
agent=agents.Agent(
name="researcher",
instructions="Find information on the given topic",
tools=[web_search]
)
result=awaitagents.run(agent, inputs.query)
returnself.Outputs(findings=result.output)

Implementation Sketch

Module Structure

python-sdk/
exospherehost/
openai/
__init__.py # exports agents
agents.py # Agent, run() wrapper
_runner.py # Internal execution logic

Core Wrapper

# exospherehost/openai/agents.pyfromopenai_agentsimportAgentasOpenAIAgent, RunnerfromexospherehostimportStateManager# Re-export Agent class unchangedAgent=OpenAIAgentasyncdefrun(agent: Agent, message: str, retry_policy: dict=None):
""" Execute an OpenAI agent with Exosphere reliability. - Tracks execution as a state - Applies retry policy on failure - Records output for observability """# For prototype: direct execution with retry wrapper# Future: create state in State Manager, execute via Runtimemax_retries=retry_policy.get("max_retries", 0) ifretry_policyelse0forattemptinrange(max_retries+1):
try:
result=awaitRunner.run(agent, message)
returnresultexceptExceptionase:
ifattempt==max_retries:
raise# Apply backoff strategyawaitasyncio.sleep(2**attempt)

Open Questions

  1. How deep should integration go?

    • Shallow: Just wrap run() with retries
    • Deep: Each tool call is a separate Exosphere state
  2. How to handle streaming?

  3. Multi-agent handoffs?

    • Model as graph edges between AgentNodes?
    • Or let OpenAI SDK handle internally?
  4. Dependency management?

    • Make openai-agents an optional dependency
    • pip install exospherehost[openai]

Effort Estimate

TaskEffort
Module structure + exports0.5 days
Basic run() wrapper with retries1 day
State tracking integration1-2 days
Dashboard visibility1 day
Documentation + examples1 day
Testing1 day

Total: 5-7 days for prototype


Success Criteria

  • Developer can from exospherehost.openai import agents
  • Agent execution has automatic retries
  • Executions visible in Exosphere dashboard
  • Works alongside existing graph-based workflows
  • No changes required to existing OpenAI agent code

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions