fix: Include graph schemas for marketplace agents in Agent Generator - #11920
Conversation
When marketplace agents are included in the library_agents payload to the Agent Generator service, they were missing required fields (graph_id, graph_version, input_schema, output_schema), causing Pydantic validation to fail with HTTP 422. Changes: - Add agent_graph_id field to StoreAgent model - Include agentGraphId in hybrid search SQL query - Update search_marketplace_agents_for_generation to fetch full graph schemas for marketplace agents - Marketplace agents now return LibraryAgentSummary (unified type) with complete schemas for sub-agent composition - Update deduplication logic to use graph_id instead of name This fixes agent creation failures on dev where the decompose-description endpoint was returning 422 Unprocessable Entity. Fixes: SECRT-1817
WalkthroughSearch now returns library-style summaries with full input/output schemas by looking up store-listed graphs; Changes
Sequence DiagramsequenceDiagram
participant Client as Client/API
participant Generator as AgentGenerator
participant StoreSearch as MarketplaceStoreSearch
participant GraphStore as GraphStore
Client->>Generator: search_marketplace_agents_for_generation(query)
Generator->>StoreSearch: search marketplace agents (returns entries with agent_graph_id)
StoreSearch-->>Generator: marketplace entries (agent_graph_id list)
Generator->>GraphStore: get_store_listed_graphs(graph_id_1..n)
GraphStore-->>Generator: GraphModel(s) with graph_id, graph_version, input_schema, output_schema
Generator->>Generator: enrich entries -> LibraryAgentSummary, dedupe by graph_id
Generator-->>Client: list[LibraryAgentSummary]
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🧰 Additional context used📓 Path-based instructions (1)autogpt_platform/frontend/**/*.{ts,tsx,json}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧠 Learnings (1)📚 Learning: 2026-01-28T18:29:18.309ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
🔇 Additional comments (3)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Move asyncio import to module level - Create get_graphs_by_ids batch function with varargs - Remove duck typing - properly handle nullable agent_graph_id - Remove obvious comments
The StoreAgent view defines agentGraphId as String (non-nullable). Using empty string default for backward compatibility - empty strings are falsy and filtered out in the agent generation code.
Updated StoreAgent model to have agent_graph_id as required str. Updated test files to include the new required field.
Replaced asyncio.gather with a single Prisma find_many query using id IN operator. This is more efficient than N concurrent calls.
- Added get_graphs_by_ids to backend/data/graph.py - Uses StoreListingVersion lookup (same pattern as get_graph for public graphs) - Removed inline Prisma query from feature code
Clearer name indicating these are store-listed public graphs that don't require permission checks.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.py`:
- Line 382: Remove the inline comment "# Deduplicate by graph_id (marketplace
agents now have full schemas)" from the deduplication block that references
graph_id in the agent generation logic in core.py (the section handling
marketplace agent schema deduplication), leaving only the code that performs the
dedupe; no code changes beyond deleting that comment.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.pyautogpt_platform/backend/backend/api/features/store/model.pyautogpt_platform/backend/backend/api/features/store/model_test.pyautogpt_platform/backend/backend/api/features/store/routes_test.pyautogpt_platform/backend/backend/data/graph.py
🚧 Files skipped from review as they are similar to previous changes (1)
- autogpt_platform/backend/backend/api/features/store/model.py
🧰 Additional context used
📓 Path-based instructions (5)
autogpt_platform/backend/**/*.py
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
autogpt_platform/backend/**/*.py: Always run backend setup commands in order: poetry install, poetry run prisma migrate dev, poetry run prisma generate before backend development
Always run poetry run format (Black + isort) before poetry run lint (ruff) for backend code
Use Python 3.10-3.13 with Python 3.11 required for development (managed by Poetry via pyproject.toml)
autogpt_platform/backend/**/*.py: Use FastAPI with async support for API endpoints in the backend
Use Prisma ORM for database operations with PostgreSQL
Use RabbitMQ for async task processing in the backend
Use JWT-based authentication with Supabase integration
Usepoetry run format(Black + isort) to format code andpoetry run lint(ruff) for linting in the backend
Use ClamAV integration for file upload security
autogpt_platform/backend/**/*.py: Format Python code withpoetry run format
Runpoetry run test(runs pytest with a docker based postgres + prisma) before committing backend changes
Files:
autogpt_platform/backend/backend/data/graph.pyautogpt_platform/backend/backend/api/features/store/routes_test.pyautogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.pyautogpt_platform/backend/backend/api/features/store/model_test.py
autogpt_platform/backend/backend/data/**/*.py
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
All data access in backend data/*.py files must include user ID validation checks
Files:
autogpt_platform/backend/backend/data/graph.py
autogpt_platform/**/*.{ts,tsx,js,py}
📄 CodeRabbit inference engine (AGENTS.md)
Avoid comments at all times unless the code is very complex
Files:
autogpt_platform/backend/backend/data/graph.pyautogpt_platform/backend/backend/api/features/store/routes_test.pyautogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.pyautogpt_platform/backend/backend/api/features/store/model_test.py
autogpt_platform/**/data/*.py
📄 CodeRabbit inference engine (AGENTS.md)
For changes touching
data/*.py, validate user ID checks or explain why not needed
Files:
autogpt_platform/backend/backend/data/graph.py
autogpt_platform/backend/**/*_test.py
📄 CodeRabbit inference engine (autogpt_platform/CLAUDE.md)
autogpt_platform/backend/**/*_test.py: Place test files colocated with source files using*_test.pynaming convention
Use pytest for backend testing with snapshot testing for API responses
Update snapshots usingpoetry run pytest path/to/test.py --snapshot-updateand review changes withgit diffbefore committing
Files:
autogpt_platform/backend/backend/api/features/store/routes_test.pyautogpt_platform/backend/backend/api/features/store/model_test.py
🧠 Learnings (2)
📚 Learning: 2025-11-25T08:48:33.246Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T08:48:33.246Z
Learning: Applies to autogpt_platform/backend/backend/server/routers/**/*.py : When updating API routes in backend, modify routes in /backend/backend/server/routers/, add/update Pydantic models in same directory, write tests alongside route files, validate user ID checks for data/*.py changes, and run poetry run test
Applied to files:
autogpt_platform/backend/backend/api/features/store/routes_test.py
📚 Learning: 2026-01-28T18:29:18.309Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:18.309Z
Learning: Applies to autogpt_platform/backend/backend/server/routers/**/*.py : Update block API routes in `/backend/backend/server/routers/` and add/update Pydantic models in the same directory
Applied to files:
autogpt_platform/backend/backend/api/features/store/routes_test.py
🧬 Code graph analysis (2)
autogpt_platform/backend/backend/data/graph.py (1)
autogpt_platform/backend/backend/api/features/library/model.py (2)
from_db(125-262)from_db(388-423)
autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.py (1)
autogpt_platform/backend/backend/data/graph.py (1)
get_store_listed_graphs(1031-1061)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: types
- GitHub Check: Seer Code Review
- GitHub Check: test (3.12)
- GitHub Check: test (3.13)
- GitHub Check: test (3.11)
- GitHub Check: Check PR Status
🔇 Additional comments (11)
autogpt_platform/backend/backend/api/features/store/routes_test.py (6)
73-86: LGTM — fixture now includesagent_graph_id.
Line 85 updates the featured-agent fixture to cover the new field.
119-132: LGTM — creator fixture aligned with new field.
Line 131 addsagent_graph_idto the creator-specific agent fixture.
165-178: LGTM — sorted agents fixture updated.
Line 177 includesagent_graph_idfor the sorted response fixture.
300-314: LGTM — pagination fixture updated foragent_graph_id.
Line 312 extends the list-comprehension fixture to include the new field.
366-385: LGTM — details fixture now includesagent_graph_id.
Line 380 adds the field toStoreAgentDetailsto keep fixtures in sync.
435-447: LGTM — creators pagination fixture aligned.
Line 444 addsagent_graph_idto the creator response fixture.autogpt_platform/backend/backend/api/features/store/model_test.py (2)
18-35: LGTM — StoreAgent test now validatesagent_graph_id.
Line 35 adds the assertion for the new field.
38-56: LGTM — StoreAgentsResponse fixture updated.
Line 51 addsagent_graph_id, keeping the response test aligned.autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.py (2)
10-18: LGTM — import aligns with new graph hydration flow.
Line 17 addsget_store_listed_graphs, which is now used by marketplace search.
267-315: LGTM — marketplace agents now include full schemas.
Lines 273-313 correctly hydrate graph data and returnLibraryAgentSummarywith schemas.autogpt_platform/backend/backend/data/graph.py (1)
1031-1061:⚠️ Potential issue | 🟠 MajorAdd required user ID validation to this data-layer function.
Line 1031 introduces a new data access path without any user ID validation; please add a user_id parameter and validate it (or otherwise enforce the required check) and update call sites accordingly.🔧 Suggested direction (update callers to pass user_id)
-async def get_store_listed_graphs(*graph_ids: str) -> dict[str, GraphModel]: +async def get_store_listed_graphs(user_id: str, *graph_ids: str) -> dict[str, GraphModel]: """Batch-fetch multiple store-listed graphs by their IDs. @@ - if not graph_ids: + if not user_id: + raise ValueError("user_id is required") + if not graph_ids: return {}As per coding guidelines, all data access in backend data/*.py files must include user ID validation checks.
⛔ Skipped due to learnings
Learnt from: CR Repo: Significant-Gravitas/AutoGPT PR: 0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-11-25T08:48:33.246Z Learning: Applies to autogpt_platform/backend/backend/data/**/*.py : All data access in backend data/*.py files must include user ID validation checksLearnt from: CR Repo: Significant-Gravitas/AutoGPT PR: 0 File: AGENTS.md:0-0 Timestamp: 2026-01-28T18:29:47.950Z Learning: Applies to autogpt_platform/**/data/*.py : For changes touching `data/*.py`, validate user ID checks or explain why not needed
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
- Add missing agent_graph_id field to StoreAgent test fixtures - Update marketplace agent tests to match new LibraryAgentSummary format - Regenerate frontend openapi.json to include agent_graph_id
- Use 'or empty string' for agent_graph_id in hybrid search to satisfy str type - Remove invalid agent_graph_id from StoreAgentDetails and Creator test fixtures
6f74627 to
a70f091
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
autogpt_platform/frontend/src/app/api/openapi.json (1)
9836-9851:⚠️ Potential issue | 🟠 MajorStoreAgent marks
agent_graph_idas required—field can be empty in backend responsesThe backend db layer defaults
agent_graph_idto empty string when source data is missing (agent.get("agentGraphId", "")), and downstream code explicitly filters out agents with empty/falsyagent_graph_idvalues. Marking this field as required in the OpenAPI schema is therefore too strict and will cause generated clients/validators to reject valid responses containing empty values. Either ensure the backend always populates a non-empty value (including historical data) or make the field optional/nullable in the schema.🔧 Recommended schema adjustment
- "agent_graph_id": { "type": "string", "title": "Agent Graph Id" } + "agent_graph_id": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Agent Graph Id" + } ... - "agent_graph_id"
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
autogpt_platform/backend/snapshots/agts_by_creatorautogpt_platform/backend/snapshots/agts_paginationautogpt_platform/backend/snapshots/agts_sortedautogpt_platform/backend/snapshots/feat_agtsautogpt_platform/frontend/src/app/api/openapi.json
✅ Files skipped from review due to trivial changes (1)
- autogpt_platform/backend/snapshots/agts_sorted
🧰 Additional context used
📓 Path-based instructions (1)
autogpt_platform/frontend/**/*.{ts,tsx,json}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use Node.js 21+ with pnpm package manager for frontend development
Files:
autogpt_platform/frontend/src/app/api/openapi.json
🧠 Learnings (1)
📚 Learning: 2026-01-28T18:29:18.309Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/CLAUDE.md:0-0
Timestamp: 2026-01-28T18:29:18.309Z
Learning: Applies to autogpt_platform/backend/**/*_test.py : Update snapshots using `poetry run pytest path/to/test.py --snapshot-update` and review changes with `git diff` before committing
Applied to files:
autogpt_platform/backend/snapshots/feat_agts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: chromatic
- GitHub Check: e2e_test
- GitHub Check: lint
- GitHub Check: types
- GitHub Check: Seer Code Review
- GitHub Check: test (3.11)
- GitHub Check: test (3.13)
- GitHub Check: test (3.12)
- GitHub Check: Check PR Status
🔇 Additional comments (3)
autogpt_platform/backend/snapshots/feat_agts (1)
12-13: LGTM!The snapshot correctly reflects the new
agent_graph_idfield added to theStoreAgentmodel. The test value"test-graph-1"is appropriate for fixture data.autogpt_platform/backend/snapshots/agts_pagination (1)
12-13: LGTM!The
agent_graph_idfield has been consistently added to all agent entries. Using the same test value across agents is acceptable for pagination testing purposes.Also applies to: 24-25, 36-37, 48-49, 60-61
autogpt_platform/backend/snapshots/agts_by_creator (1)
12-13: LGTM!The snapshot correctly incorporates the new
agent_graph_idfield, maintaining consistency with the updatedStoreAgentschema.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Problem
When marketplace agents are included in the
library_agentspayload sent to the Agent Generator service, they were missing required fields (graph_id,graph_version,input_schema,output_schema). This caused Pydantic validation to fail with HTTP 422 Unprocessable Entity.Root cause: The
MarketplaceAgentSummaryTypedDict had a different shape thanLibraryAgentInfoexpected by the Agent Generator:graph_id,graph_version,name,description,input_schema,output_schemaname,description,sub_heading,creator,is_marketplace_agentSolution
agent_graph_idtoStoreAgentmodel - The field was already in the database view but not exposedagentGraphIdin hybrid search SQL query - Carry the field through the search CTEssearch_marketplace_agents_for_generation()- Now fetches full graph schemas usingget_graph()and returnsLibraryAgentSummary(same type as library agents)graph_idinstead of name for more accurate deduplicationChanges
backend/api/features/store/model.py: Add optionalagent_graph_idfield toStoreAgentbackend/api/features/store/hybrid_search.py: IncludeagentGraphIdin SQL query columnsbackend/api/features/store/db.py: MapagentGraphIdwhen creatingStoreAgentobjectsbackend/api/features/chat/tools/agent_generator/core.py: Updatesearch_marketplace_agents_for_generation()to fetch and include full graph schemasTesting
Fixes: SECRT-1817