Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion python/packages/hosting-responses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,21 @@ from fastapi.responses import JSONResponse
app = FastAPI()
state = AgentState(agent)

# Request options are caller-controlled; pass through only the ones this route honors.
ALLOWED_REQUEST_OPTIONS = frozenset({"max_tokens", "reasoning"})


@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)
options = {key: value for key, value in run["options"].items() if key in ALLOWED_REQUEST_OPTIONS}
result = await (await state.get_target()).run(
run["messages"],
session=session,
options=run["options"],
options=options,
)
if is_conversation_id:
# The app must serialize writers that advance this stable id.
Expand Down
Loading