Skip to content

Conversation

@kcze
Copy link
Contributor

@kcze kcze commented Nov 13, 2025

Make onboarding task completion backend-authoritative which prevents cheating (previously users could mark all tasks as completed instantly and get rewards) and makes task completion more reliable. Completion of tasks is moved backend with exception of introductory onboarding tasks and visit-page type tasks.

Changes 🏗️

  • Move incrementing run counter backend and make webhook-triggered and scheduled task execution count as well
  • Use user timezone for calculating run streak
  • Frontend task completion is moved from update onboarding state to separate endpoint and guarded so only frontend tasks can be completed
  • Graph creation, execution and add marketplace agent to library accept source, so appropriate tasks can be completed
  • Replace client.ts api calls with orval generated and remove no longer used functions from client.ts
  • Add resolveResponse helper function that unwraps orval generated call result to 2xx response

Small changes&bug fixes:

  • Make Redis notification bus serialize all payload fields
  • Fix confetti when group is finished
  • Collapse finished group when opening Wallet
  • Play confetti only for tasks that are listed in the Wallet UI

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • Onboarding can be finished
    • All tasks can be finished and work properly
    • Confetti works properly

@kcze kcze requested a review from majdyz November 17, 2025 11:21
@kcze kcze marked this pull request as ready for review November 17, 2025 11:21
@kcze kcze requested a review from a team as a code owner November 17, 2025 11:21
@qodo-merge-pro
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Type Validation

The POST /onboarding/step handler validates the 'step' argument using get_args on FrontendOnboardingStep. FastAPI/Orval may coerce values differently; ensure the request body schema strictly restricts values and that invalid enum strings are rejected as intended.

async def onboarding_complete_step(
    user_id: Annotated[str, Security(get_user_id)], step: FrontendOnboardingStep
):
    if step not in get_args(FrontendOnboardingStep):
        raise HTTPException(status_code=400, detail="Invalid onboarding step")
    return await complete_onboarding_step(user_id, step)
Concurrency

increment_runs reads onboarding then updates counters and computes milestones based on old completedSteps. In concurrent executions, milestones or counters might race. Consider doing the update and step computation in a transaction or re-fetching state after update to avoid duplicate or missed completions.

async def increment_runs(user_id: str):
    """
    Increment a user's run counters and trigger any onboarding milestones.
    """
    user_timezone = await _get_user_timezone(user_id)
    onboarding = await get_user_onboarding(user_id)
    new_run_count = onboarding.agentRuns + 1
    last_run_at, consecutive_run_days = _calculate_consecutive_run_days(
        onboarding.lastRunAt, onboarding.consecutiveRunDays, user_timezone
    )

    await UserOnboarding.prisma().update(
        where={"userId": user_id},
        data={
            "agentRuns": new_run_count,
            "lastRunAt": last_run_at,
            "consecutiveRunDays": consecutive_run_days,
        },
    )

    milestones = _get_run_milestone_steps(new_run_count, consecutive_run_days)
    new_steps = [step for step in milestones if step not in onboarding.completedSteps]

    for step in new_steps:
        await complete_onboarding_step(user_id, step)
Backward Compatibility

Notification payload now enforces event type and OnboardingNotificationPayload.step as OnboardingStep and allows extras via model_config. Verify all producers/consumers (WS, Redis serializer) handle this shape and that older clients expecting string step don't break.

    type: str
    event: str

    model_config = pydantic.ConfigDict(extra="allow")


class OnboardingNotificationPayload(NotificationPayload):
    step: OnboardingStep

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Nov 19, 2025
@github-actions
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Nov 20, 2025
@github-actions
Copy link
Contributor

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

majdyz
majdyz previously approved these changes Nov 20, 2025
@github-project-automation github-project-automation bot moved this from 🆕 Needs initial review to 👍🏼 Mergeable in AutoGPT development kanban Nov 20, 2025
ntindle
ntindle previously approved these changes Nov 26, 2025
@kcze kcze requested a review from a team as a code owner November 26, 2025 09:02
@kcze kcze force-pushed the kpczerwinski/secrt-1726-move-completion-backend branch from 3039e20 to 69cb8a1 Compare November 26, 2025 09:29
@github-actions
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Nov 27, 2025
Copy link
Contributor

@0ubbe 0ubbe left a comment

Choose a reason for hiding this comment

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

Code looks good, nice cleanp Front-end side 👍🏽 💯

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

Labels

conflicts Automatically applied to PRs with merge conflicts platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end Review effort 4/5 size/xl

Projects

Status: 👍🏼 Mergeable
Status: No status

Development

Successfully merging this pull request may close these issues.

6 participants