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(backend): Add ability to execute store agents without agent ownership #9179

Conversation

Swiftyos
Copy link
Contributor

@Swiftyos Swiftyos commented Jan 3, 2025

Description

This PR enables the execution of store agents even if they are not owned by the user. Key changes include handling store-listed agents in the get_graph logic, improving execution flow, and ensuring version-specific handling. These updates support more flexible agent execution.

Changes 🏗️

  • Graph Retrieval: Updated get_graph to check store listings for agents not owned by the user.
  • Version Handling: Added graph_version to execution methods for consistent version-specific execution.
  • Execution Flow: Refactored scheduler.py, rest_api.py, and other modules for clearer logic and better maintainability.
  • Testing: Updated test_manager.py and other test cases to validate execution of store-listed agents added test for accessing graph

Copy link

supabase bot commented Jan 3, 2025

This pull request has been ignored for the connected project bgwpwdsxblryihinutbx because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Copy link
Contributor

github-actions bot commented Jan 3, 2025

This PR targets the master branch but does not come from dev or a hotfix/* branch.

Automatically setting the base branch to dev.

@github-actions github-actions bot changed the base branch from master to dev January 3, 2025 10:27
@github-actions github-actions bot added platform/backend AutoGPT Platform - Back end size/m labels Jan 3, 2025
Copy link

netlify bot commented Jan 3, 2025

Deploy Preview for auto-gpt-docs ready!

Name Link
🔨 Latest commit 99bc218
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/678103e2e6bda40008dd9d12
😎 Deploy Preview https://deploy-preview-9179--auto-gpt-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Swiftyos Swiftyos marked this pull request as ready for review January 3, 2025 12:35
@Swiftyos Swiftyos requested a review from a team as a code owner January 3, 2025 12:35
@Swiftyos Swiftyos requested review from Bentlybro and majdyz and removed request for a team January 3, 2025 12:35
Copy link

qodo-merge-pro bot commented Jan 3, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

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

Access Control

The new store listing access check logic should be carefully reviewed to ensure it properly restricts access to only published store agents and prevents unauthorized access to private agents.

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 is not a store listing, return None
if not store_listing:
    return None

# If it is a store listing, return the graph model
return GraphModel.from_db(graph, for_export) if graph else None
Breaking Change

The graph_version parameter was made required in add_execution() which could break existing code that doesn't pass this parameter. Verify all callers have been updated.

def add_execution(
    self,
    graph_id: str,
    data: BlockInput,
    user_id: str,
    graph_version: int,
) -> GraphExecutionEntry:
    graph: GraphModel | None = self.db_client.get_graph(
        graph_id=graph_id, user_id=user_id, version=graph_version
    )

Copy link

netlify bot commented Jan 3, 2025

Deploy Preview for auto-gpt-docs-dev ready!

Name Link
🔨 Latest commit 99bc218
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs-dev/deploys/678103e24340890008bf9419
😎 Deploy Preview https://deploy-preview-9179--auto-gpt-docs-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

…without-agent-ownership' of github.com:Significant-Gravitas/AutoGPT into swiftyos/open-2276-add-ability-to-execute-store-agents-without-agent-ownership
@Swiftyos Swiftyos requested a review from Pwuts January 7, 2025 15:59
@Pwuts Pwuts changed the title feature(platform): add ability to execute store agents without agent ownership feature(backend): Add ability to execute store agents without agent ownership Jan 7, 2025
majdyz
majdyz previously approved these changes Jan 8, 2025
autogpt_platform/backend/backend/data/graph.py Outdated Show resolved Hide resolved
autogpt_platform/backend/backend/data/graph.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added size/l and removed size/m labels Jan 9, 2025
@Swiftyos Swiftyos requested a review from majdyz January 9, 2025 11:26
@Swiftyos Swiftyos enabled auto-merge January 9, 2025 11:31
Swiftyos and others added 3 commits January 9, 2025 16:04
…without-agent-ownership' of github.com:Significant-Gravitas/AutoGPT into swiftyos/open-2276-add-ability-to-execute-store-agents-without-agent-ownership
majdyz
majdyz previously approved these changes Jan 9, 2025
@majdyz majdyz disabled auto-merge January 9, 2025 19:01
…without-agent-ownership' of github.com:Significant-Gravitas/AutoGPT into swiftyos/open-2276-add-ability-to-execute-store-agents-without-agent-ownership
@Swiftyos Swiftyos merged commit 00bb7c6 into dev Jan 10, 2025
20 checks passed
@Swiftyos Swiftyos deleted the swiftyos/open-2276-add-ability-to-execute-store-agents-without-agent-ownership branch January 10, 2025 11:39
Swiftyos added a commit that referenced this pull request Jan 10, 2025
…ctionality (#9218)

### 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

---------

Co-authored-by: Reinier van der Leer <[email protected]>
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.

3 participants