Openai Django Sessions
Description
Django ORM-based session backend for the OpenAI Agents SDK
Installation
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open the source below and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
README
openai-django-sessions
Django ORM-based session backend for the [OpenAI Agents SDK](https://github.com/openai/openai-agents-python).
Store your agent conversation history in any Django-supported database (PostgreSQL, MySQL, SQLite, etc.) with full async support.
Installation
pip install openai-django-sessions
Requirements
- Python 3.12+
- Django 5.0+
- openai-agents 0.1.0+
Quick Start
from agents import Agent, Runner
from openai_django_sessions import DjangoSession
async def chat():
# Create a session (auto-creates tables in development)
session = DjangoSession("user-123", create_tables=True)
agent = Agent(name="Assistant", instructions="You are a helpful assistant.")
# First message
result = await Runner.run(agent, "Hello!", session=session)
print(result.final_output)
# Follow-up (session maintains conversation history)
result = await Runner.run(agent, "What did I just say?", session=session)
print(result.final_output)
Usage
Basic Usage
from openai_django_sessions import DjangoSession
# Simple instantiation
session = DjangoSession("user-123")
# With auto table creation (for development/testing)
session = DjangoSession("user-123", create_tables=True)
Custom Table Names
session = DjangoSession(
"user-123",
sessions_table="my_agent_sessions",
messages_table="my_agent_messages",
create_tables=True,
)
Using with Django Settings
# Semantic alias that uses Django's configured database
session = DjangoSession.from_settings("user-123", create_tables=True)
API Reference
DjangoSession
class DjangoSession(SessionABC):
def __init__(
self,
session_id: str,
*,
sessions_table: str = "agent_sessions",
messages_table: str = "agent_messages",
create_tables: bool = False,
) -> None: ...
@classmethod
def from_settings(
cls,
Related Skills
Awesome Go
A curated list of awesome Go frameworks, libraries and software
Development next.js
| The React Framework | 138360 | 1503 | 1 |
Development sharing-skills
skill for guidance.
Development root-cause-tracing
Use when errors occur deep in execution and you need to trace back to find the original trigger.
Development Template Skill
Minimal skeleton for a new skill project structure.
Development Third-party Notices
THE FOLLOWING SETS FORTH ATTRIBUTION NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THI
Development