INNER CODE UNIT · Python
agent_turn
genome-spy/genome-spy · packages/app-agent/server/app/main.py:126
async def agent_turn(
request: AgentTurnRequest,
http_request: Request,
stream: bool = Query(default=False),
) -> AgentTurnResponse | StreamingResponse:
"""Handle one browser-to-model agent turn.
Builds the provider request from the browser payload, logs prompt-token
diagnostics, and returns either a normal response or an SSE stream.
Args:
request: Browser request payload for the current agent turn.
http_request: Incoming FastAPI request used to inspect client headers.
stream: Whether the caller explicitly requested server-sent events.
Returns:
Final agent-turn payload or a streaming SSE response, depending on the request.