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

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

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 007954c
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs-dev/deploys/67f833aba2acdc00080735db

Copy link

deepsource-io bot commented Apr 8, 2025

Here's the code health analysis summary for commits 8ea3bfa..007954c. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ Success
❗ 2 occurences introduced
🎯 4 occurences resolved
View Check ↗
DeepSource Python LogoPython✅ Success
❗ 31 occurences introduced
🎯 31 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 007954c
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/67f833abd18456000748c4bb

@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.

@github-actions github-actions bot added size/l and removed size/xl labels Apr 10, 2025
@github-actions github-actions bot added size/xl and removed size/l labels Apr 10, 2025
@Pwuts Pwuts marked this pull request as ready for review April 10, 2025 15:57
@Pwuts Pwuts requested a review from a team as a code owner April 10, 2025 15:57
@Pwuts Pwuts requested review from Swiftyos and aarushik93 and removed request for a team April 10, 2025 15:57
@Pwuts Pwuts changed the title feat(backend): Agent Presets feat(backend): Agent Presets backend improvements Apr 10, 2025
@Pwuts Pwuts requested review from ntindle, kcze and majdyz and removed request for Swiftyos April 10, 2025 15:59
@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.

@@ -232,7 +234,7 @@ async def create_library_agent(
isCreatedByUser=(user_id == graph.user_id),
useGraphIsActiveVersion=True,
User={"connect": {"id": user_id}},
# Creator={"connect": {"id": agent.userId}},
# Creator={"connect": {"id": graph.user_id}},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this commented out?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure, it was like that when I found it

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we annotate and find out the context?

@github-project-automation github-project-automation bot moved this from 🆕 Needs initial review to 👍🏼 Mergeable in AutoGPT development kanban Apr 11, 2025
@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Apr 11, 2025
Copy link
Contributor

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

@@ -113,7 +126,12 @@ async def create_preset(
HTTPException: If an error occurs while creating the preset.
"""
try:
return await db.upsert_preset(user_id, preset)
if isinstance(preset, models.LibraryAgentPresetCreatable):
return await db.create_preset(user_id, preset)
Copy link
Contributor

Choose a reason for hiding this comment

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

This pattern is not neat. We've been catching exceptions through middleware, we can just generally return 404 on any not found exception error that way rather than spamming try catch in all of our endpoint code, similarly with 500.

@majdyz
Copy link
Contributor

majdyz commented Apr 21, 2025

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

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 size/xl
Projects
Status: 👍🏼 Mergeable
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants