Skip to content

feat(backend): Agent Presets backend improvements #9786

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

Merged
merged 17 commits into from
Jun 5, 2025

Conversation

Pwuts
Copy link
Member

@Pwuts Pwuts commented Apr 8, 2025

Changes 🏗️

Backend:

  • Fix+improve GET /library/presets (list_presets) endpoint

    • Fix pagination
    • Add graph_id filter parameter
  • Allow partial preset updates: PUT /presets/{preset_id} -> PATCH /presets/{preset_id}

  • Allow creating preset from graph execution through POST /presets

  • Clean up models & DB functions

    • Split upsert_preset into create_preset + update_preset
    • Add LibraryAgentPresetUpdatable
    • Replace CreateLibraryAgentPresetRequest with LibraryAgentPresetCreatable
      • Use LibraryAgentPresetCreatable as base class for LibraryAgentPreset
    • Remove redundant set_is_deleted_for_library_agent(..)
    • Improve log statements
    • Improve DB statements (e.g. by using unique keys where possible)

Frontend:

  • Add timestamp parsing logic to library agent preset endpoints
  • Brand LibraryAgentPreset.id + references

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:
    • CI green
    • Since these changes don't affect existing front-end functionality, no additional testing is needed.

…dpoints)

Frontend:
- Add logic to fetch, select/view, and create presets to `/library/agents/[id]`
- refactor: Brand `LibraryAgentPreset.id` + references

Backend:
- Add `graph_id` filter parameter to `GET /library/presets` (`list_presets`) endpoint
@github-project-automation github-project-automation bot moved this to 🆕 Needs initial review in AutoGPT development kanban Apr 8, 2025
@github-actions github-actions bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end labels Apr 8, 2025
@github-actions github-actions bot added the size/l label Apr 8, 2025
Copy link

netlify bot commented Apr 8, 2025

Deploy Preview for auto-gpt-docs-dev canceled.

Name Link
🔨 Latest commit bd9dd84
🔍 Latest deploy log https://app.netlify.com/projects/auto-gpt-docs-dev/deploys/6841bbba4d3de400081e4b8e

Copy link

deepsource-io bot commented Apr 8, 2025

Here's the code health analysis summary for commits 7d10dc4..bd9dd84. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ Success
❗ 2 occurences introduced
🎯 17 occurences resolved
View Check ↗
DeepSource Python LogoPython✅ Success
❗ 3 occurences introduced
🎯 4 occurences resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link

netlify bot commented Apr 8, 2025

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit bd9dd84
🔍 Latest deploy log https://app.netlify.com/projects/auto-gpt-docs/deploys/6841bbbab20bce00082d37d3

@Pwuts Pwuts mentioned this pull request Apr 8, 2025
9 tasks
@github-actions github-actions bot added size/xl and removed size/l labels Apr 9, 2025
github-merge-queue bot pushed a commit that referenced this pull request Apr 10, 2025
Distilled from #9541 to reduce the scope of that PR.

- Part of #9307

- ❗ Blocks #9786
  - ❗ Blocks #9541

### Changes 🏗️

- Fix `LibraryAgent` schema (for #9786)
- Fix relationships between `LibraryAgent`, `AgentGraph`, and
`AgentPreset`
  - Impose uniqueness constraint on `LibraryAgent`

- Rename things that are called `agent` that actually refer to a
`graph`/`agentGraph`
- Fix singular/plural forms in DB schema
- Simplify reference names of closely related objects (e.g.
`AgentGraph.AgentGraphExecutions` -> `AgentGraph.Executions`)

- Eliminate use of `# type: ignore` in DB statements
  - Add `typed` and `typed_cast` utilities to `backend.util.type`

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
- [x] CI static type checking (with all risky `# type: ignore` removed)
  - [x] Check that column references in views are updated
@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Apr 10, 2025
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 Apr 10, 2025
Copy link
Contributor

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

majdyz
majdyz previously approved these changes Apr 21, 2025
@majdyz
Copy link
Contributor

majdyz commented Apr 21, 2025

Let me know when you have resolved the conflicts so I can reapprove

@Pwuts Pwuts dismissed stale reviews from majdyz and kcze via 7a6b243 May 19, 2025 22:25
@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label May 19, 2025
Copy link
Contributor

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

@github-actions github-actions bot added size/l and removed size/xl labels May 19, 2025
@Pwuts Pwuts requested a review from majdyz May 19, 2025 22:27
@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label May 24, 2025
Copy link
Contributor

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

@majdyz majdyz removed their request for review May 26, 2025 16:19
ntindle
ntindle previously approved these changes Jun 5, 2025
@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Jun 5, 2025
Copy link
Contributor

github-actions bot commented Jun 5, 2025

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

@Pwuts Pwuts enabled auto-merge June 5, 2025 15:48
@Pwuts Pwuts added this pull request to the merge queue Jun 5, 2025
Merged via the queue into dev with commit 781f138 Jun 5, 2025
27 checks passed
@Pwuts Pwuts deleted the pwuts/secrt-1215-agent-presets-back-end branch June 5, 2025 16:41
@github-project-automation github-project-automation bot moved this to Done in Frontend Jun 5, 2025
@github-project-automation github-project-automation bot moved this from 👍🏼 Mergeable to ✅ Done in AutoGPT development kanban Jun 5, 2025
Swiftyos added a commit that referenced this pull request Jun 17, 2025
- Follow-up fix for #9786

A change to a DB statement introduced in #9786 turns out to be breaking.
Apparently `connect` can't just be used for *some* relations: if it is
used, it must be used for *all* relations created by the statement.

### Changes 🏗️

- Fix broken DB statement in `add_store_agent_to_library(..)`

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
  - [x] Add store agent to library

Co-authored-by: Swifty <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Jun 24, 2025
This pull request adds support for setting up (webhook-)triggered agents
in the Library. It contains changes throughout the entire stack to make
everything work in the various phases of a triggered agent's lifecycle:
setup, execution, updates, deletion.

Setting up agents with webhook triggers was previously only possible in
the Builder, limiting their use to the agent's creator only. To make it
work in the Library, this change uses the previously introduced
`AgentPreset` to store information on, instead of on the graph's nodes
to which only a graph's creator has access.

- Initial ticket: #10111
- Builds on #9786

![screenshot of trigger setup screen in the
library](https://github.com/user-attachments/assets/525b4e94-d799-4328-b5fa-f05d6a3a206a)
![screenshot of trigger edit screen in the
library](https://github.com/user-attachments/assets/e67eb0bc-df70-4a75-bf95-1c31263ef0c9)

### Changes 🏗️

Frontend:
- Amend the Library's `AgentRunDraftView` to handle creating and editing
Presets
- Add `hideIfSingleCredentialAvailable` parameter to `CredentialsInput`
  - Add multi-select support to `TypeBasedInput`
- Add Presets section to `AgentRunsSelectorList`
  - Amend `AgentRunSummaryCard` for use for Presets
- Add `AgentStatusChip` to display general agent status (for now: Active
/ Inactive / Error)
- Add Preset loading logic and create/update/delete handlers logic to
`AgentRunsPage`
- Rename `IconClose` to `IconCross`

API:
- Add `LibraryAgent` properties `has_external_trigger`,
`trigger_setup_info`, `credentials_input_schema`
- Add `POST /library/agents/{library_agent_id}/setup_trigger` endpoint
- Remove redundant parameters from `POST
/library/presets/{preset_id}/execute` endpoint

Backend:
- Add `POST /library/agents/{library_agent_id}/setup_trigger` endpoint
- Extract non-node-related logic from `on_node_activate` into
`setup_webhook_for_block`
- Add webhook-related logic to `update_preset` and `delete_preset`
endpoints
- Amend webhook infrastructure to work with AgentPresets
  - Add preset trigger support to webhook ingress endpoint
- Amend executor stack to work with passed-in node input
(`nodes_input_masks`, generalized from `node_credentials_input_map`)
    - Amend graph validation to work with passed-in node input
  - Add `AgentPreset`->`IntegrationWebhook` relation
    - Add `WebhookWithRelations` model
- Change behavior of `BaseWebhooksManager.get_manual_webhook(..)` to
avoid unnecessary changes of the webhook URL: ignore `events` to find
matching webhook, and update `events` if necessary.
- Fix & improve `AgentPreset` API, models, and DB logic
  - Add `isDeleted` filter to get/list queries
  - Add `user_id` attribute to `LibraryAgentPreset` model
  - Add separate `credentials` property to `LibraryAgentPreset` model
- Fix `library_db.update_preset(..)` replacement of existing
`InputPresets`
- Make `library_db.update_preset(..)` more usage-friendly with separate
parameters for updateable properties
- Add `user_id` checks to various DB functions
- Fix error handling in various endpoints
- Fix cache race condition on `load_webhook_managers()`

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
  - Test existing functionality
- [x] Auto-setup and -teardown of webhooks on save in the builder still
works
    - [x] Running an agent normally from the Library still works
  - Test new functionality
    - [x] Setting up a trigger in the Library
    - [x] Updating a trigger in the Library
    - [x] Disabling and re-enabling a trigger in the Library
    - [x] Deleting a trigger in the Library
- [x] Triggers set up in the Library result in a new run when the
webhook receives a payload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end size/l
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants