Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(platform): Implement library add, update, remove, archive functionality #9218

Open
wants to merge 21 commits into
base: dev
Choose a base branch
from

Conversation

Swiftyos
Copy link
Contributor

@Swiftyos Swiftyos commented Jan 8, 2025

Changes πŸ—οΈ

  1. Core Features:

    • Add agents to the user's library.
    • Update library agents (auto-update, favorite, archive, delete).
    • Paginate library agents and presets.
    • Execute graphs using presets.
  2. Refactoring:

    • Replaced UserAgent with LibraryAgent.
    • Separated routes for agents and presets.
  3. Schema Changes:

    • Added LibraryAgent table with fields like isArchived, isDeleted, etc.
    • Soft delete functionality for AgentPreset.
  4. Testing:

    • Updated tests for LibraryAgent operations.
    • Added edge case tests for deletion, archiving, and pagination.
  5. Database Migrations:

    • Migration to drop UserAgent and add LibraryAgent.
    • Added fields for soft deletion and auto-update.

Note this includes the changes from the following PR's to avoid merge conflicts with them:

#9179
#9211

Swiftyos and others added 19 commits January 3, 2025 11:26
…without-agent-ownership' of github.com:Significant-Gravitas/AutoGPT into swiftyos/open-2276-add-ability-to-execute-store-agents-without-agent-ownership
…without-agent-ownership' into swiftyos/open-2277-implement-library-add-update-remove-archive-functionality
@Swiftyos Swiftyos requested a review from a team as a code owner January 8, 2025 09:45
@Swiftyos Swiftyos requested review from ntindle and aarushik93 and removed request for a team January 8, 2025 09:45
@github-actions github-actions bot added platform/backend AutoGPT Platform - Back end size/xl and removed platform/backend AutoGPT Platform - Back end labels Jan 8, 2025
Copy link

qodo-merge-pro bot commented Jan 8, 2025

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

Access Control

The updated graph access logic needs careful review to ensure proper authorization - it now checks both user ownership and store listing access but the logic flow could potentially have edge cases.

if graph.userId == user_id:
    return GraphModel.from_db(graph, for_export) if graph else None

# If the graph is not owned by the user, we need to check if it's a store listing.
if not version:
    version = graph.version

store_listing_where: StoreListingWhereInput = {
    "agentId": graph_id,
    "agentVersion": version,
}

store_listing = await StoreListing.prisma().find_first(where=store_listing_where)

# If it does not belong to the user nor is not a store listing, return None
if not store_listing:
    return None

# If it is a store listing, return the graph model
Input Validation

The preset execution endpoint merges preset inputs with node inputs without validation. Need to verify this doesn't allow overriding critical preset values.

merged_input = {**preset.inputs, **node_input}
Error Handling

The library agent update function needs review of error cases, particularly around version conflicts when auto-updating agents.

async def update_agent_version_in_library(
    user_id: str, agent_id: str, agent_version: int
) -> None:
    """
    Updates the agent version in the library
    """
    try:
        await prisma.models.LibraryAgent.prisma().update(
            where={
                "userId": user_id,
                "agentId": agent_id,
                "useGraphIsActiveVersion": True,
            },
            data=prisma.types.LibraryAgentUpdateInput(
                Agent=prisma.types.AgentGraphUpdateOneWithoutRelationsInput(
                    connect=prisma.types.AgentGraphWhereUniqueInput(
                        id=agent_id,
                        version=agent_version,
                    ),
                ),
            ),
        )
    except prisma.errors.PrismaError as e:
        logger.error(f"Database error updating agent version in library: {str(e)}")
        raise backend.server.v2.store.exceptions.DatabaseError(
            "Failed to update agent version in library"
        ) from e

Copy link

netlify bot commented Jan 8, 2025

βœ… Deploy Preview for auto-gpt-docs-dev canceled.

Name Link
πŸ”¨ Latest commit bc8043b
πŸ” Latest deploy log https://app.netlify.com/sites/auto-gpt-docs-dev/deploys/677e4ccb26ec43000861781e

Copy link

netlify bot commented Jan 8, 2025

βœ… Deploy Preview for auto-gpt-docs canceled.

Name Link
πŸ”¨ Latest commit bc8043b
πŸ” Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/677e4ccbe247990008badad8

@github-actions github-actions bot added the platform/backend AutoGPT Platform - Back end label Jan 8, 2025
@aarushik93 aarushik93 removed their request for review January 8, 2025 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant