Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

agent-framework-hosting-responses

OpenAI Responses-shaped helpers for app-owned Agent Framework hosting.

This package provides the Responses-specific conversion layer:

  • responses_to_run(...) — convert a Responses request body into Agent Framework run values.
  • responses_session_id(...) — return (session_id, is_conversation_id) for a prior resp_* response id or conv_* conversation id, or (None, None) when neither is present.
  • create_conversation_id(...) — mint a Responses-shaped conversation id.
  • create_response_id(...) — mint a Responses-shaped response id.
  • responses_from_run(...) — convert an AgentResponse into a Responses-compatible JSON payload.
  • responses_from_streaming_run(...) — convert an Agent Framework ResponseStream into Responses-compatible SSE events.

FastAPI/Starlette/Django/Azure Functions code owns route registration, authentication, status codes, response construction, and background work.

from agent_framework_hosting import AgentState
from agent_framework_hosting_responses import (
    create_response_id,
    responses_from_run,
    responses_session_id,
    responses_to_run,
)
from fastapi import Body, FastAPI
from fastapi.responses import JSONResponse

app = FastAPI()
state = AgentState(agent)


@app.post("/responses")
async def responses(body: dict = Body(...)) -> JSONResponse:
    run = responses_to_run(body)
    session_id, is_conversation_id = responses_session_id(body)
    response_id = create_response_id()
    session = await state.get_or_create_session(session_id or response_id)
    result = await (await state.get_target()).run(
        run["messages"],
        session=session,
        options=run["options"],
    )
    if is_conversation_id:
        # The app must serialize writers that advance this stable id.
        await state.set_session(session_id, session)
    else:
        await state.set_session(response_id, session)
    conversation_id = session_id if is_conversation_id else None
    return JSONResponse(responses_from_run(result, response_id=response_id, conversation_id=conversation_id))

previous_response_id identifies an immutable continuation snapshot: multiple requests may branch from it and store their results under distinct new response ids. conversation_id is a mutable head instead; only one caller should advance it at a time. These helpers do not provide per-conversation locking.

AgentState lives in agent-framework-hosting. The experimental in-memory and file-backed session stores live in core as agent_framework.SessionStore and agent_framework.FileSessionStore.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file agent_framework_hosting_responses-1.0.0a260730.tar.gz.

File metadata

  • Download URL: agent_framework_hosting_responses-1.0.0a260730.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agent_framework_hosting_responses-1.0.0a260730.tar.gz
Algorithm Hash digest
SHA256 6a12577a99259ef1bc96967c02a996bc5fe3e0cefa417a127abffe6b9182e189
MD5 c0dce49a56c531810cfc1fecce6089a9
BLAKE2b-256 b3d58dec0916c531169ca4c003080b874b3c1c7c091153116e00317cefb1ddda

See more details on using hashes here.

File details

Details for the file agent_framework_hosting_responses-1.0.0a260730-py3-none-any.whl.

File metadata

  • Download URL: agent_framework_hosting_responses-1.0.0a260730-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agent_framework_hosting_responses-1.0.0a260730-py3-none-any.whl
Algorithm Hash digest
SHA256 fe9b4ab68334d81299630c76fe00842b1615d845e1c36bf28b5d78471795ce7a
MD5 c20475a4bdc48769ef9f35b05353b93b
BLAKE2b-256 3b64a09bc514bfa4d683ee818a824879ecc777bc1b780858494e96e116878b8a

See more details on using hashes here.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page