Repository navigation
fix(agent): add canvas_type filter and field to list_agents API - #15754
Conversation
- 在 agent API 中新增 canvas_type 参数支持 - 修改 list_agents 函数以接收 canvas_type 查询参数 - 更新 CanvasService.query 方法以支持 canvas_type 筛选条件 - 在查询字段中添加 canvas_type 字段 - 实现基于 canvas_type 的数据过滤逻辑
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR adds canvas type filtering to the agent listing endpoint. The agent API now accepts a ChangesCanvas Type Filtering for Agent List
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
api/db/services/canvas_service.py (1)
144-215: ⚡ Quick winConsider adding logging to improve observability of canvas_type filtering.
The
get_by_tenant_idsmethod now supports canvas_type filtering, but the filter application is not logged. Other query methods in this service (list_tagsat lines 233-238 andupdate_tagsat lines 272-277) include structured logging. Adding a log statement would help with debugging and usage tracking, similar to the pattern used in those methods.📊 Suggested logging addition
# Add after line 215, before the return statement logging.info( "UserCanvasService.get_by_tenant_ids user=%s canvas_category=%s canvas_type=%s tags=%s keywords=%s count=%d", user_id, canvas_category, canvas_type, tags, keywords, count, )As per coding guidelines: "Add logging for new flows" for
**/*.py.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/db/services/canvas_service.py` around lines 144 - 215, The get_by_tenant_ids method applies canvas_type filtering but doesn't log it; add a structured logging.info call in UserCanvasService.get_by_tenant_ids (just before the return) that records user_id, canvas_category, canvas_type, tags, keywords and the computed count to match the pattern used in list_tags/update_tags; use the existing logging module and the agents/count variables (e.g., reference agents_list/count/user_id/canvas_category/canvas_type/tags/keywords) so the filter and result size are observable.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@api/db/services/canvas_service.py`:
- Around line 144-215: The get_by_tenant_ids method applies canvas_type
filtering but doesn't log it; add a structured logging.info call in
UserCanvasService.get_by_tenant_ids (just before the return) that records
user_id, canvas_category, canvas_type, tags, keywords and the computed count to
match the pattern used in list_tags/update_tags; use the existing logging module
and the agents/count variables (e.g., reference
agents_list/count/user_id/canvas_category/canvas_type/tags/keywords) so the
filter and result size are observable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0503fc59-c144-4c4c-a08a-c4c0bce43035
📒 Files selected for processing (2)
api/apps/restful_apis/agent_api.pyapi/db/services/canvas_service.py
|
The head branch of this PR lives in an external fork and cannot be updated via the current reviewer token. Please rebase against git fetch origin main
git rebase origin/main
# or
git merge origin/mainIf the 403 persists after pushing, please contact the repository maintainers to verify fork write permissions.
|
Done |
…niflow#15754) ### What problem does this PR solve? GET /api/v1/agents (list_agents) already supports filtering by canvas_category, keywords, tags, and owner_ids, but it does not support canvas_type — even though canvas_type is a persisted field on UserCanvas and is already accepted on agent create/update APIs. This gap causes two issues: Filtering — clients cannot list agents by business category (e.g. Marketing, Agent, Ingestion Pipeline) without fetching all agents and filtering client-side. Response payload — list_agents did not return canvas_type in each canvas item, so consumers had to call GET /api/v1/agents/{id} per agent to read it. This PR adds optional canvas_type query parameter support and includes canvas_type in the list response. ### Type of change - [√] Bug Fix (non-breaking change which fixes an issue) - [ ] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe):
What problem does this PR solve?
GET /api/v1/agents (list_agents) already supports filtering by canvas_category, keywords, tags, and owner_ids, but it does not support canvas_type — even though canvas_type is a persisted field on UserCanvas and is already accepted on agent create/update APIs.
This gap causes two issues:
Filtering — clients cannot list agents by business category (e.g. Marketing, Agent, Ingestion Pipeline) without fetching all agents and filtering client-side.
Response payload — list_agents did not return canvas_type in each canvas item, so consumers had to call GET /api/v1/agents/{id} per agent to read it.
This PR adds optional canvas_type query parameter support and includes canvas_type in the list response.
Type of change