Skip to content

feat(framework): Add Open Responses compatible /responses endpoint to Runtime API - #7941

Open
charlesbvll wants to merge 58 commits into
mainfrom
add-runtime-responses-endpoint
Open

feat(framework): Add Open Responses compatible /responses endpoint to Runtime API#7941
charlesbvll wants to merge 58 commits into
mainfrom
add-runtime-responses-endpoint

Conversation

@charlesbvll

@charlesbvll charlesbvll commented Aug 19, 2026

Copy link
Copy Markdown
Member

New Flow

  AgentApp
    │ OpenAI SDK: POST /v1/runtime/responses
    │ Authorization: Bearer <AgentApp task token>
    ▼
  Flower Responses endpoint
    │ creates child MODEL task + stores ModelRequest
    ▼
  flwr-model
    │ calls configured model provider
    │ publishes Open Responses events
    ▼
  Flower endpoint
    │ relays events as SSE
    ▼
  OpenAI SDK stream iterator

Decisions made

  • Expose POST /v1/runtime/responses through a regular FastAPI JSON/SSE router because the existing Runtime router uses ProtobufRoute
  • Authenticate with Authorization: Bearer <task-token> so standard Open Responses-compatible SDKs can call the endpoint directly
  • Accept only AgentApp task tokens
  • Reuse the existing model execution path by creating a child flwr-model task and sending it the existing ModelRequest
  • Keep provider routing, task relationships, run attribution, and usage accounting unchanged
  • Support both non-streaming JSON responses and SSE streaming in the initial implementation
  • Initially support only the fields already represented by ModelRequest
    • model
    • input
    • stream
    • tools
    • tool_choice
    • reasoning
    • previous_response_id
    • instructions
    • max_output_tokens
    • metadata
    • text
  • Reject unsupported fields explicitly instead of silently ignoring them
  • Correlate replies atomically through reply_to_message_id
    • Model replies for concurrent requests share the same AgentApp destination
    • Filtering must happen inside the destructive CoreState claim so one request cannot consume another request's reply
  • Filter stream events by the child model task so unrelated events from the same run cannot enter the SDK stream
  • Consume the final task reply before exposing a terminal SSE event, preventing it from remaining in the AgentApp mailbox
  • Mark unfinished child model tasks as STOPPED when the request times out or the client disconnects
  • Inject FLWR_RUNTIME_BASE_URL and FLWR_RUNTIME_API_KEY before loading the AgentApp
  • Keep the existing agent.responses.create(...) path unchanged
  • Do not add the OpenAI SDK as a framework runtime dependency
  • No database migration is required because reply correlation and task IDs are already stored

Open questions

  • Is the initial request-field subset sufficient for the first release -> Yes we keep just the used subset
  • Which additional Open Responses event types, if any, need explicit support
  • Should HTTP errors follow the exact OpenAI error contract, including status codes and error fields, or is compatibility at the SDK level sufficient
  • Is marking the child task as STOPPED enough on disconnect, or should we also add executor-level cancellation to terminate an in-flight provider request immediately
  • Should agent.responses.create(...) eventually become a wrapper around this endpoint or remain on its current lower-level Runtime path -> We leave it unchanged for now
  • Should the OpenAI SDK end-to-end example be included in this PR or added separately

Deps

@github-actions github-actions Bot added the Maintainer Used to determine what PRs (mainly) come from Flower maintainers. label Aug 19, 2026
# Conflicts:
#	framework/py/flwr/simulation/app.py
#	framework/py/flwr/simulation/simulationio_connection.py
#	framework/py/flwr/supercore/cli/flower_superexec.py
#	framework/py/flwr/supercore/task_process/agent/run_agentapp.py
#	framework/py/flwr/supercore/task_process/connector/run_connector.py
#	framework/py/flwr/supercore/task_process/model/run_model.py
#	framework/py/flwr/superlink/runtime/run_serverapp.py
#	framework/py/flwr/supernode/runtime/run_clientapp.py
# Conflicts:
#	framework/py/flwr/superlink/cli/flower_superlink.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1387d0c882

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread framework/py/flwr/superlink/routers/runtime/responses.py Outdated
Comment thread framework/py/flwr/supercore/task_process/agent/run_agentapp.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1efe8c45bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread framework/py/flwr/superlink/routers/runtime/responses.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7182df9e7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread framework/py/flwr/superlink/routers/runtime/responses.py
Comment thread framework/py/flwr/supercore/task_process/agent/run_agentapp.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 533818a120

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread framework/py/flwr/superlink/routers/runtime/responses.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bfa19d24d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread framework/py/flwr/superlink/routers/runtime/responses.py Outdated
Comment thread framework/proto/flwr/proto/runtime.proto
if certificates is None:
return None

# OpenAI/httpx reads custom CAs from SSL_CERT_FILE, which requires a path.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@panh99 I'm not sure about this bit of code it seems different to the certificates that we have in the codebase. Can you check this?

Comment thread framework/proto/flwr/proto/runtime.proto
Comment thread framework/py/flwr/superlink/routers/runtime/__init__.py
Comment thread framework/py/flwr/superlink/routers/runtime/responses.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e972c14c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread framework/py/flwr/supercore/task_process/agent/run_agentapp.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c061a6a06c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread framework/py/flwr/superlink/routers/runtime/responses.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d5e28e3ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread framework/py/flwr/superlink/routers/runtime/responses.py
@@ -0,0 +1,437 @@
# Copyright 2026 Flower Labs GmbH. All Rights Reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we unify the runtime/responses and agent/session.py? Right now we have the duplication
RuntimeAgentResponses.create()
→ CreateTask
→ PushTaskMessage
→ poll PullTaskMessage

POST /v1/runtime/responses
→ CreateTask
→ store_task_message
→ poll LinkState

The CreateTask > Push/StoreTaskMessage > Poll can be unified.

@danielnugraha danielnugraha left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split this PR to make it more manageable?

  1. proto and corestate changes
  2. create a shared file that both POST /v1/runtime/responses and RuntimeAgentResponses.create calls
  3. POST /v1/runtime/responses implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintainer Used to determine what PRs (mainly) come from Flower maintainers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants