{"record":{"id":"d2d192cac94f0609","repo":"bytedance/deer-flow","slug":"after-seq-is-not-supported-by-this-backward-only-e","errorCode":null,"errorMessage":"after_seq is not supported by this backward-only endpoint","messagePattern":"after_seq is not supported by this backward-only endpoint","errorType":"validation","errorClass":"HTTPException","httpStatus":422,"severity":"error","filePath":"backend/app/gateway/routers/thread_runs.py","lineNumber":1353,"sourceCode":"    # multi-step turn (#4152). The legacy ``GET /messages`` and ``/history``\n    # endpoints already use ``stamp_turn_duration_on_last_ai``; the page\n    # endpoint was inlining the equivalent loop but stamping every AI row,\n    # which #4163 fixed for the other paths and missed here.\n    stamp_turn_duration_on_last_ai(data, run_durations)\n    return data\n\n\n@router.get(\"/{thread_id}/messages/page\", response_model=ThreadMessagesPageResponse)\n@require_permission(\"runs\", \"read\", owner_check=True)\nasync def list_thread_messages_page(\n    thread_id: ThreadId,\n    request: Request,\n    limit: int = Query(default=50, ge=1, le=200),\n    before_seq: int | None = Query(default=None, ge=1),\n) -> ThreadMessagesPageResponse:\n    \"\"\"Return a backward page ordered by the thread-global event sequence.\"\"\"\n    if \"after_seq\" in request.query_params:\n        raise HTTPException(status_code=422, detail=\"after_seq is not supported by this backward-only endpoint\")\n\n    user_id = await get_current_user(request)\n    rows, has_more = await _scan_thread_message_page(\n        thread_id,\n        limit=limit,\n        before_seq=before_seq,\n        request=request,\n        user_id=user_id,\n    )\n    data = await _enrich_thread_message_page(thread_id, rows, request=request, user_id=user_id)\n    return ThreadMessagesPageResponse(\n        data=data,\n        has_more=has_more,\n        next_before_seq=data[0][\"seq\"] if has_more else None,\n    )\n\n\n@router.get(\"/{thread_id}/runs/{run_id}/messages\")","sourceCodeStart":1335,"sourceCodeEnd":1371,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/thread_runs.py#L1335-L1371","documentation":"Error \"after_seq is not supported by this backward-only endpoint\" thrown in bytedance/deer-flow.","triggerScenarios":"Thrown at backend/app/gateway/routers/thread_runs.py:1353 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use before_seq for paging backwards; this endpoint only supports backward pagination.","Remove after_seq from the request."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}