Skip to content

feat(backend): add workspace file move/copy and workspace folder tools - #13700

Open
Abhi1992002 wants to merge 4 commits into
devfrom
secrt-2441
Open

feat(backend): add workspace file move/copy and workspace folder tools#13700
Abhi1992002 wants to merge 4 commits into
devfrom
secrt-2441

Conversation

@Abhi1992002

Copy link
Copy Markdown
Member

Why / What / How

Why. The workspace file API had no move or copy primitive. The only way to relocate a file was a three-call workaround:

  1. read_workspace_file(file_id, save_to_path=...) — downloads the whole file into the sandbox
  2. write_workspace_file(filename, path, source_path=...) — uploads it to the new path
  3. delete_workspace_file(file_id) — deletes the original

That pulls the entire file through the agent's context — base64-encoded for binary — purely to change a path string. A 2.2 MB PNG burned a large slice of the context budget without a single byte ever being inspected. It also isn't atomic: if the session dies between steps 2 and 3 you end up with two copies and no way to tell which is authoritative. And it's non-obvious enough that it needed a dedicated skill entry to execute reliably — an agent observed without it fell back to rewriting file content from scratch.

Separately, workspace folders (the grouping shown on the Artifacts page, backed by UserWorkspaceFolder) already existed with a full data layer and REST API, but were invisible to the agent — there were no tools for them at all.

What. Six new CoPilot tools:

Tool Purpose
move_workspace_file Move/rename a file to a new virtual path
copy_workspace_file Duplicate a file to a new virtual path
create_workspace_folder Create a file folder
delete_workspace_folder Delete a folder, returning its files to the root
list_workspace_folders List folders with file counts
move_workspace_files_to_folder Bulk-change folder membership

How. Both transfer operations are server-side; the bytes never enter this process or the model's context.

  • Move is metadata-only. It rewrites name/path (and optionally folderId) and deliberately leaves storagePath alone, so no bytes move at all. The stale filename segment left in the blob path is harmless — nothing reads the filename back out of storagePath; get_download_url parses out the file ID only.
  • Copy adds a copy() primitive to WorkspaceStorageBackend: a GCS server-side blob copy, and shutil.copyfile (off the event loop) for local storage. It is quota-enforced but does not re-run the virus scan, since these exact bytes were already scanned by write_file when they first entered the workspace and a copy cannot change them.

Path/folder are two orthogonal concepts here and the tools keep them that way: move_workspace_file changes the virtual path, move_workspace_files_to_folder changes folder membership, and neither affects the other. Tool descriptions spell out the distinction from the existing create_folder/delete_folder tools, which manage library folders holding agents.

Destination collisions fail by default with an error naming the conflicting path, with overwrite=true as the opt-in escape hatch — mirroring write_workspace_file. Folder deletion reparents files to the root rather than deleting them, matching the existing DELETE /api/workspace/folders/{id} behavior.

Two other issues from the ticket:

  • Misleading truncation error. Omitting only filename from write_workspace_file reported "Tool call appears truncated (no arguments received)" even when plenty of content was supplied. content/content_base64/source_path are named parameters, so probing **kwargs for them always came up empty and has_any_content was unconditionally False. Now reads the bound parameters, and the genuine no-arguments case keeps its actionable guidance.
  • Prompt guidance. The system prompt taught only the cross-storage move pattern, so the three-call workaround was the model's best available option. It now documents the in-workspace move/copy tools and explicitly warns against read-write-delete.

Changes 🏗️

New tools

  • backend/copilot/tools/workspace_file_transfer.pymove_workspace_file / copy_workspace_file, sharing argument resolution and the skills-registry ACL check (enforced on the source path, the destination path, and again on the resolved path when the target was given by file_id)
  • backend/copilot/tools/workspace_folders.py — the four folder tools; folders resolvable by ID or by case-insensitive name

Transfer layer

  • backend/util/workspace_transfer.py (new) — move_file / copy_file, including quota enforcement, collision handling, orphaned-blob cleanup when the DB insert fails, and search-index refresh (the index is keyed on name and path). Kept out of workspace.py, which is already ~520 lines
  • backend/util/workspace.py — thin move_file / copy_file delegating methods
  • backend/util/workspace_storage.py — new abstract copy() plus GCS and local implementations

Data layer

  • backend/data/workspace.py — new update_workspace_file_location, workspace-scoped via update_many (not update, which matches on primary key alone and would let a cross-workspace ID or a concurrently-deleted row through); create_workspace_file gains an optional folder_id
  • backend/data/workspace_folder.py — folder functions renamed to workspace-prefixed names so they can be exposed over the DatabaseManager RPC boundary alongside the identically-named library folder functions
  • backend/data/db_accessors.py — new workspace_folder_db() accessor
  • backend/data/db_manager.py — RPC exposure for the new file and folder functions

Registration & generated artifacts

  • backend/copilot/tools/__init__.py, backend/copilot/permissions.py, backend/copilot/tools/models.py — tool registry entries, ToolName literal entries, and response types
  • frontend/src/app/api/openapi.json — regenerated; the six new ResponseType enum values changed the exported schema
  • backend/copilot/tools/tool_schema_test.py — tool-schema character budget raised for the six new tools, after trimming their descriptions
  • docs/integrations/block-integrations/misc.md — regenerated via scripts/generate_block_docs.py

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:
    • backend/util/workspace_transfer_test.py (new, 14 tests) — move rewrites path/name without touching storage; copy delegates to the storage copy() and never calls retrieve(); quota rejection before any write; collision rejected / overwrite deletes the occupant first; same-path move is a no-op; folder preserved unless overridden; session-scoped path resolution; orphaned blob cleaned up when the DB insert conflicts
    • backend/copilot/tools/workspace_file_transfer_test.py (new, 19 tests) — response shapes, auth, argument validation, skills-registry ACL by path and by file_id, error surfacing
    • backend/copilot/tools/workspace_folders_test.py (new, 20 tests) — all four folder tools including duplicate names, case-insensitive lookup, move-to-root, and files silently dropped as out-of-workspace being reported rather than counted as success
    • backend/util/workspace_storage_test.py — local copy duplicates bytes and leaves the source intact; missing source raises; GCS copy uses server-side copy without downloading
    • backend/copilot/tools/workspace_files_test.py — regression tests for the missing-filename error; verified 4 of the 5 fail against the old code while the genuine-truncation case still passes
    • Mutation-checked the transfer suite: breaking basename derivation fails exactly the two tests that assert it
    • Verified tool registry and ToolName literal agree, and that every renamed folder function resolves on both the direct-import and RPC paths
    • poetry run format, poetry run lint, pyright, and pnpm types clean; 272 tests pass locally

Note: the DB-backed suites (folder_routes_test.py and the round-trip tests in workspace_files_test.py) could not run in my sandbox — the session-scoped autouse fixture needs Docker Postgres, which isn't available there. Their patch targets were updated for the rename and verified to resolve by import; they run in CI.

For configuration changes:

  • .env.default is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
  • I have included a list of my configuration changes in the PR description (under Changes)

No configuration changes.

Add server-side move/copy primitives and folder-management CoPilot tools
for the workspace file API.

Previously the only way to relocate a workspace file was a 3-call
read -> write -> delete workaround that streamed the entire file
(base64 for binaries) through the agent context, was non-atomic, and
needed a documented skill to execute reliably.

New CoPilot tools:
- move_workspace_file / copy_workspace_file
- create_workspace_folder / delete_workspace_folder / list_workspace_folders
- move_workspace_files_to_folder

Move is metadata-only (no bytes move); copy uses a server-side blob copy
(GCS server-side copy / shutil.copyfile off the event loop), is
quota-enforced, and skips the redundant virus scan since the bytes were
already scanned on entry.
@Abhi1992002
Abhi1992002 requested a review from a team as a code owner July 28, 2026 15:12
@Abhi1992002
Abhi1992002 requested review from Bentlybro and Pwuts and removed request for a team July 28, 2026 15:12
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Jul 28, 2026
@Abhi1992002

Copy link
Copy Markdown
Member Author

/review

@github-actions github-actions Bot added documentation Improvements or additions to documentation platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end labels Jul 28, 2026
@autogpt-pr-reviewer

Copy link
Copy Markdown

Queued a review for PR #13700 at c623714.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d17e29a5-1b36-4a2e-8b49-c5b907e38123

📥 Commits

Reviewing files that changed from the base of the PR and between 560448f and 9b7dbd7.

📒 Files selected for processing (1)
  • autogpt_platform/backend/backend/data/workspace_test.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • autogpt_platform/backend/backend/data/workspace_test.py
📜 Recent review details
⏰ Context from checks skipped due to timeout. (18)
  • GitHub Check: check API types
  • GitHub Check: lint
  • GitHub Check: integration_test
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.11)
  • GitHub Check: type-check (3.12)
  • GitHub Check: test (3.13)
  • GitHub Check: type-check (3.13)
  • GitHub Check: lint
  • GitHub Check: type-check (3.11)
  • GitHub Check: end-to-end tests
  • GitHub Check: Seer Code Review
  • GitHub Check: Analyze (typescript)
  • GitHub Check: check-docs-sync
  • GitHub Check: types
  • GitHub Check: Analyze (python)
  • GitHub Check: Check PR Status
  • GitHub Check: lint

Walkthrough

Adds server-side workspace file move/copy operations and Copilot tools for workspace folder management. The change updates database access, storage backends, tool registration, permissions, API routes, response models, validation, tests, OpenAPI metadata, and integration documentation.

Changes

Workspace organization

Layer / File(s) Summary
Workspace data and folder API
backend/data/*, backend/api/features/workspace/*
Workspace-folder entry points are renamed, workspace file locations gain folder persistence, database-manager mappings are added, and folder routes/tests use the database module.
Server-side file transfer
backend/util/workspace*.py
File moves update metadata without copying bytes; copies use backend-native storage operations with quota, collision, cleanup, and reindex handling.
Copilot transfer tools and exposure
backend/copilot/tools/workspace_file_transfer.py, backend/copilot/tools/__init__.py, backend/copilot/permissions.py, backend/copilot/prompting.py
Move and copy tools validate sources and destinations, protect skills paths, return structured responses, and are registered and documented.
Copilot folder tools
backend/copilot/tools/workspace_folders.py, backend/copilot/tools/workspace_folders_test.py
Adds authenticated folder creation, deletion, listing, and bulk file movement with folder resolution and partial-success responses.
Tool validation and metadata updates
backend/copilot/tools/workspace_files.py, frontend/src/app/api/openapi.json, docs/integrations/block-integrations/misc.md
Improves missing-filename validation and updates schema limits, action identifiers, and permitted tool documentation.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Copilot
  participant TransferTool
  participant WorkspaceManager
  participant Storage
  participant Database
  Copilot->>TransferTool: request move or copy
  TransferTool->>WorkspaceManager: execute file operation
  WorkspaceManager->>Storage: copy object when duplicating
  WorkspaceManager->>Database: update or create file metadata
  Database-->>TransferTool: return WorkspaceFile
  TransferTool-->>Copilot: return structured response
Loading

Possibly related PRs

Suggested reviewers: pwuts, bentlybro

Poem

I’m a rabbit with folders to tend,
Moving files where neat paths now extend.
Copy bytes server-side, quick as a hare,
Keep skills paths protected with care.
New tools hop into the registry bright—
Workspace tidier by moonlight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Clearly summarizes the main addition of workspace file move/copy and folder tools.
Description check ✅ Passed The description accurately matches the changeset and main goals of the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch secrt-2441

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
Comment thread autogpt_platform/backend/backend/util/workspace_transfer.py
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.15774% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.71%. Comparing base (bdc2b5f) to head (9b7dbd7).
⚠️ Report is 31 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #13700      +/-   ##
==========================================
+ Coverage   76.64%   76.71%   +0.07%     
==========================================
  Files        2715     2722       +7     
  Lines      207923   208929    +1006     
  Branches    19947    19991      +44     
==========================================
+ Hits       159370   160288     +918     
- Misses      44153    44284     +131     
+ Partials     4400     4357      -43     
Flag Coverage Δ
platform-backend 83.31% <94.15%> (+0.06%) ⬆️
platform-frontend 47.61% <ø> (-0.02%) ⬇️
platform-frontend-e2e 31.01% <ø> (-0.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 83.31% <94.15%> (+0.06%) ⬆️
Platform Frontend 51.31% <ø> (-0.08%) ⬇️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
autogpt_platform/backend/backend/data/workspace.py (1)

125-185: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Validate folder_id ownership before persisting folder membership.

create_workspace_file(...) and update_workspace_file_location(...) write folderId directly; folder_id supplied by callers such as move_file/copy_file is forwarded unchanged and is not required to belong to workspace_id. The same folder-write pattern already guards ownership with _get_folder_record(folder_id, workspace_id), so mirror that check here before creating/updating the file record.

🤖 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 `@autogpt_platform/backend/backend/data/workspace.py` around lines 125 - 185,
Validate non-null folder_id belongs to workspace_id before persisting it in
create_workspace_file and update_workspace_file_location, using the existing
_get_folder_record(folder_id, workspace_id) ownership check. Ensure callers such
as move_file and copy_file cannot attach a file to a folder from another
workspace, while preserving root-folder behavior when folder_id is None.

Source: Path instructions

🧹 Nitpick comments (2)
autogpt_platform/backend/backend/copilot/tools/workspace_folders.py (1)

1-453: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

File exceeds the ~300-line guideline.

This new file is ~454 lines. Consider splitting by responsibility — e.g., move the response models (WorkspaceFolderCreatedResponse, WorkspaceFolderDeletedResponse, WorkspaceFolderListResponse, WorkspaceFilesMovedToFolderResponse) and _to_info/_resolve_folder helpers into a separate module, or split the single-folder tools (create/delete/list) from the bulk-move tool into two files.

Based on path instructions: "Keep files under ~300 lines; if a file grows beyond this, split by responsibility (extract helpers, models, or a sub-module into a new file)."

🤖 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 `@autogpt_platform/backend/backend/copilot/tools/workspace_folders.py` around
lines 1 - 453, Split workspace_folders.py to keep it under the ~300-line
guideline, separating the bulk-move responsibility from the single-folder tools.
Move MoveWorkspaceFilesToFolderTool into a dedicated module and update
imports/registration as needed, while keeping the shared WorkspaceFolder
response models and helpers (_to_info and _resolve_folder) reusable without
duplicating them.

Source: Path instructions

autogpt_platform/backend/backend/data/workspace_folder_test.py (1)

29-137: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider a direct unit test for bulk_move_files_to_folder.

The renamed tests here cover create/update/delete but not the new bulk_move_files_to_folder transaction (scope-building, cross-workspace ID dropping, move+read-back in one tx). It's only exercised via mocks in higher layers; a direct test against the Prisma call args (similar to test_delete_folder_reparents_files_then_soft_deletes) would catch regressions in the transaction/scope logic itself.

🤖 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 `@autogpt_platform/backend/backend/data/workspace_folder_test.py` around lines
29 - 137, Add a direct unit test for bulk_move_files_to_folder, covering
transaction-scoped file updates and read-back. Assert workspace scoping, removal
of IDs from other workspaces, the move operation’s target folder, and that both
Prisma calls use the same transaction client; follow the call-argument and
ordering assertions used by
test_delete_folder_reparents_files_then_soft_deletes.
🤖 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.

Inline comments:
In `@autogpt_platform/backend/backend/copilot/tools/workspace_files.py`:
- Around line 845-848: Update the argument-presence check in the workspace file
tool around has_any_content to use is not None rather than truthiness, so
explicitly supplied empty strings count as provided. Include path and mime_type
in the check, along with the other non-default bound inputs relevant to
identifying a truly empty tool call, while preserving the existing truncation
behavior.

In `@autogpt_platform/backend/backend/util/workspace_transfer.py`:
- Around line 34-35: Update move_file and copy_file to validate any supplied
folder_id through a workspace-scoped folder lookup before calling
db.update_workspace_file_location or creating the copied file. Require
UserWorkspaceFolder.workspaceId to match the UserWorkspaceFile.workspaceId, and
reject or fail the operation when the folder is missing or belongs to another
workspace. Apply this validation to every folderId write path identified in
these functions.

---

Outside diff comments:
In `@autogpt_platform/backend/backend/data/workspace.py`:
- Around line 125-185: Validate non-null folder_id belongs to workspace_id
before persisting it in create_workspace_file and
update_workspace_file_location, using the existing _get_folder_record(folder_id,
workspace_id) ownership check. Ensure callers such as move_file and copy_file
cannot attach a file to a folder from another workspace, while preserving
root-folder behavior when folder_id is None.

---

Nitpick comments:
In `@autogpt_platform/backend/backend/copilot/tools/workspace_folders.py`:
- Around line 1-453: Split workspace_folders.py to keep it under the ~300-line
guideline, separating the bulk-move responsibility from the single-folder tools.
Move MoveWorkspaceFilesToFolderTool into a dedicated module and update
imports/registration as needed, while keeping the shared WorkspaceFolder
response models and helpers (_to_info and _resolve_folder) reusable without
duplicating them.

In `@autogpt_platform/backend/backend/data/workspace_folder_test.py`:
- Around line 29-137: Add a direct unit test for bulk_move_files_to_folder,
covering transaction-scoped file updates and read-back. Assert workspace
scoping, removal of IDs from other workspaces, the move operation’s target
folder, and that both Prisma calls use the same transaction client; follow the
call-argument and ordering assertions used by
test_delete_folder_reparents_files_then_soft_deletes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6efb0012-c757-42a1-b140-29fc5eaa3fe3

📥 Commits

Reviewing files that changed from the base of the PR and between bdc2b5f and c623714.

📒 Files selected for processing (25)
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/frontend/src/app/api/openapi.json
  • docs/integrations/block-integrations/misc.md
📜 Review details
⏰ Context from checks skipped due to timeout. (14)
  • GitHub Check: integration_test
  • GitHub Check: lint
  • GitHub Check: check API types
  • GitHub Check: Seer Code Review
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (typescript)
  • GitHub Check: end-to-end tests
  • GitHub Check: type-check (3.13)
  • GitHub Check: test (3.12)
  • GitHub Check: type-check (3.11)
  • GitHub Check: type-check (3.12)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: Check PR Status
🧰 Additional context used
📓 Path-based instructions (8)
autogpt_platform/backend/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/backend/**/*.py: Use Python 3.11 (required; managed by Poetry via pyproject.toml) for backend development
Always run 'poetry run format' (Black + isort) before linting in backend development
Always run 'poetry run lint' (ruff) after formatting in backend development

autogpt_platform/backend/**/*.py: Use poetry run ... command for executing Python package dependencies
Use top-level imports only — avoid local/inner imports except for lazy imports of heavy optional dependencies like openpyxl
Use absolute imports with from backend.module import ... for cross-package imports; single-dot relative imports are acceptable for sibling modules within the same package; avoid double-dot relative imports
Do not use duck typing — avoid hasattr/getattr/isinstance for type dispatch; use typed interfaces/unions/protocols instead
Use Pydantic models over dataclass/namedtuple/dict for structured data
Do not use linter suppressors — no # type: ignore, # noqa, # pyright: ignore; fix the type/code instead
Prefer list comprehensions over manual loop-and-append patterns
Use early return with guard clauses first to avoid deep nesting
Use %s for deferred interpolation in debug log statements for efficiency; use f-strings elsewhere for readability (e.g., logger.debug("Processing %s items", count) vs logger.info(f"Processing {count} items"))
Sanitize error paths by using os.path.basename() in error messages to avoid leaking directory structure
Be aware of TOCTOU (Time-Of-Check-Time-Of-Use) issues — avoid check-then-act patterns for file access and credit charging
Use transaction=True for Redis pipelines to ensure atomicity on multi-step operations
Use max(0, value) guards for computed values that should never be negative
Keep files under ~300 lines; if a file grows beyond this, split by responsibility (extract helpers, models, or a sub-module into a new file)
Keep functions under ~40 lines; extract named helpers when a function grows longer
...

Files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
autogpt_platform/backend/backend/data/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

All data access in backend requires user ID checks; verify this for any 'data/*.py' changes

Files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/data/workspace.py
autogpt_platform/{backend,autogpt_libs}/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.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/db_accessors.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/data/workspace.py
docs/integrations/**/*.md

📄 CodeRabbit inference engine (docs/AGENTS.md)

docs/integrations/**/*.md: Block documentation how_it_works manual section should provide a technical explanation of the block's processing logic in 1-2 paragraphs, mention validation/error handling/edge cases, and use code examples with backticks
Block documentation use_case manual section should provide exactly 3 practical use cases in bold heading format with short one-sentence descriptions
Documentation descriptions should be concise and action-oriented, focusing on practical real-world scenarios with consistent terminology and avoiding overly technical jargon

Files:

  • docs/integrations/block-integrations/misc.md
autogpt_platform/backend/**/*_test.py

📄 CodeRabbit inference engine (autogpt_platform/backend/AGENTS.md)

autogpt_platform/backend/**/*_test.py: Use pytest with snapshot testing for API responses
Colocate test files with source files using *_test.py naming convention
Mock at boundaries — mock where the symbol is used, not where it's defined; after refactoring, update mock targets to match new module paths
Use AsyncMock from unittest.mock for async functions in tests
When writing tests, use Test-Driven Development (TDD): write failing tests marked with @pytest.mark.xfail before implementation, then remove the marker once the implementation is complete
When creating snapshots in tests, use poetry run pytest path/to/test.py --snapshot-update; always review snapshot changes with git diff before committing

Files:

  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
autogpt_platform/backend/backend/api/features/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Update routes in '/backend/backend/api/features/' and add/update Pydantic models in the same directory for API development

Files:

  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
autogpt_platform/backend/**/api/**/*.py

📄 CodeRabbit inference engine (autogpt_platform/backend/AGENTS.md)

autogpt_platform/backend/**/api/**/*.py: Use Security() instead of Depends() for authentication dependencies to get proper OpenAPI security specification
Follow SSE (Server-Sent Events) protocol: use data: lines for frontend-parsed events (must match Zod schema) and : comment lines for heartbeats/status

Files:

  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
🧠 Learnings (22)
📚 Learning: 2026-02-26T17:02:22.448Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12211
File: .pre-commit-config.yaml:160-179
Timestamp: 2026-02-26T17:02:22.448Z
Learning: Keep the pre-commit hook pattern broad for autogpt_platform/backend to ensure OpenAPI schema changes are captured. Do not narrow to backend/api/ alone, since the generated schema depends on Pydantic models across multiple directories (backend/data/, backend/blocks/, backend/copilot/, backend/integrations/, backend/util/). Narrowing could miss schema changes and cause frontend type desynchronization.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-03-05T15:42:08.207Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12297
File: .claude/skills/backend-check/SKILL.md:14-16
Timestamp: 2026-03-05T15:42:08.207Z
Learning: In Python files under autogpt_platform/backend (recursively), rely on poetry run format to perform formatting (Black + isort) and linting (ruff). Do not run poetry run lint as a separate step after poetry run format, since format already includes linting checks.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-03-16T16:35:40.236Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12440
File: autogpt_platform/backend/backend/api/features/workflow_import.py:54-63
Timestamp: 2026-03-16T16:35:40.236Z
Learning: Avoid using the word 'competitor' in public-facing identifiers and text. Use neutral naming for API paths, model names, function names, and UI text. Examples: rename 'CompetitorFormat' to 'SourcePlatform', 'convert_competitor_workflow' to 'convert_workflow', '/competitor-workflow' to '/workflow'. Apply this guideline to files under autogpt_platform/backend and autogpt_platform/frontend.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-03-31T15:37:38.626Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12623
File: autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer.py:37-47
Timestamp: 2026-03-31T15:37:38.626Z
Learning: When validating/constructing Anthropic API model IDs in Significant-Gravitas/AutoGPT, allow the hyphen-separated Claude Opus 4.6 model ID `claude-opus-4-6` (it corresponds to `LlmModel.CLAUDE_4_6_OPUS` in `autogpt_platform/backend/backend/blocks/llm.py`). Do NOT require the dot-separated form in Anthropic contexts. Only OpenRouter routing variants should use the dot separator (e.g., `anthropic/claude-opus-4.6`); `claude-opus-4-6` should be treated as correct when passed to Anthropic, and flagged only if it’s used in the OpenRouter path where the dot form is expected.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-04-15T02:43:36.890Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12780
File: autogpt_platform/backend/backend/copilot/tools/workspace_files.py:0-0
Timestamp: 2026-04-15T02:43:36.890Z
Learning: When reviewing Python exception handlers, do not flag `isinstance(e, X)` checks as dead/unreachable if the caught exception `X` is a subclass of the exception type being handled. For example, if `X` (e.g., `VirusScanError`) inherits from `ValueError` (directly or via an intermediate class) and it can be raised within an `except ValueError:` block, then `isinstance(e, X)` inside that handler is reachable and should not be treated as dead code.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-05-23T05:29:43.085Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 13200
File: autogpt_platform/backend/backend/executor/scheduler.py:590-593
Timestamp: 2026-05-23T05:29:43.085Z
Learning: When reviewing Python code that uses Pydantic discriminated/tagged unions (e.g., `Annotated[Union[...], Field(discriminator="kind")]`), recognize that using `isinstance(x, SomeVariantInfo)` to narrow the union is an intentional and correct runtime guard and should also enable static type narrowing in tools like Pyright. Do not recommend replacing such `isinstance`-based narrowing with `cast(...)` when the check already proves the variant at runtime.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-04-21T04:35:34.710Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12865
File: autogpt_platform/backend/backend/data/credit.py:1584-1584
Timestamp: 2026-04-21T04:35:34.710Z
Learning: When reviewing this codebase, don’t flag snake_case attribute names (e.g., `subscription_tier`, `stripe_customer_id`, `top_up_config`) on the app-layer Pydantic `User` model as “wrong” field names. These are correct for the app-layer model and are expected to be mapped from the Prisma-layer camelCase fields (e.g., `subscriptionTier`, `stripeCustomerId`) inside methods like `User.from_db()`. Only Prisma-returned/raw objects would use camelCase, but functions like `get_user_by_id(user_id: str)` are expected to return the Pydantic app-layer model.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/data/workspace.py
📚 Learning: 2026-05-07T15:32:39.703Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 13033
File: autogpt_platform/backend/backend/data/generate_data.py:111-117
Timestamp: 2026-05-07T15:32:39.703Z
Learning: When reviewing the Python data-generation layer, do not treat missing `user_id`/user filtering in calls to graph-metadata resolvers as a security issue if the `graph_id` inputs are already guaranteed to be user-scoped by earlier upstream SQL (e.g., `WHERE "userId" = ...`). In particular, `_resolve_agent_name(graph_id)` in `generate_data.py` correctly calls `get_graph_metadata(graph_id=graph_id)` without a `user_id` parameter by design, because name resolution must also work for user-executed shared/marketplace agents that the user may not own.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/data/workspace.py
📚 Learning: 2026-04-22T11:46:04.431Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12881
File: autogpt_platform/backend/backend/copilot/config.py:0-0
Timestamp: 2026-04-22T11:46:04.431Z
Learning: Do not flag the Claude Sonnet 4.6 model ID as incorrect when it uses the project’s established hyphenated convention: `anthropic/claude-sonnet-4-6`. This hyphen form is the intentional, production convention and should be treated as valid (including in files like llm.py, blocks tests, reasoning.py, `_is_anthropic_model` tests, and config defaults). Note that OpenRouter also accepts the dot variant `anthropic/claude-sonnet-4.6`, so either form may be tolerated, but `anthropic/claude-sonnet-4-6` should be considered the standard to match project usage.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-04-22T11:46:12.892Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12881
File: autogpt_platform/backend/backend/copilot/baseline/service.py:322-332
Timestamp: 2026-04-22T11:46:12.892Z
Learning: In this codebase (Significant-Gravitas/AutoGPT), OpenRouter-routed Anthropic model IDs should use the hyphen-separated convention (e.g., `anthropic/claude-sonnet-4-6`, `anthropic/claude-opus-4-6`). Although OpenRouter may accept both hyphen and dot variants, treat the hyphen-separated form as the intended, correct codebase-wide convention and do not flag it as an error. Only flag the dot-separated variant (e.g., `anthropic/claude-sonnet-4.6`) as incorrect when reviewing/validating model ID strings for OpenRouter-routed Anthropic models.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-05-07T18:48:14.242Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 13040
File: autogpt_platform/backend/backend/blocks/llm.py:0-0
Timestamp: 2026-05-07T18:48:14.242Z
Learning: In this repository, isort may split imports from the same module into separate blocks when some imports are aliased (e.g., `from module import X as Y`) and others are not. Preserve the two-block layout when it results from isort (such as keeping `from openai.types.chat import ChatCompletion as OpenAIChatCompletion` separate from non-aliased imports from `openai.types.chat`). Do not treat that split as a style issue during review; merging them into a single block can fail CI with `Imports are incorrectly sorted and/or formatted`.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-05-26T14:24:34.866Z
Learnt from: Abhi1992002
Repo: Significant-Gravitas/AutoGPT PR: 13217
File: autogpt_platform/backend/backend/api/features/search/service.py:137-137
Timestamp: 2026-05-26T14:24:34.866Z
Learning: In the Significant-Gravitas/AutoGPT backend, treat `user_id` (an opaque UUID used only for correlation/tracing) as non-PII. Do not flag direct logging of `user_id` in `logger.warning`/`logger.info` statements as a PII exposure issue, as the established convention is to log `user_id` for tracing while reserving PII for fields like email or display name.

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-06-11T19:39:10.493Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 13337
File: autogpt_platform/backend/backend/copilot/graphiti/reranker.py:0-0
Timestamp: 2026-06-11T19:39:10.493Z
Learning: In the Significant-Gravitas/AutoGPT Python backend, when calling the OpenAI Python client `chat.completions.create`, construct the `messages` payload using the concrete typed-dict variants from `openai.types.chat` (e.g., `ChatCompletionSystemMessageParam`, `ChatCompletionUserMessageParam`, etc.) rather than trying to instantiate `ChatCompletionMessageParam` directly. `ChatCompletionMessageParam` is a `Union` alias and is not constructible, so `ChatCompletionMessageParam(role=..., content=...)` should fail type checking. Build each message element with the appropriate concrete typed dict and then annotate the resulting list as `list[ChatCompletionMessageParam]` (e.g., `messages: list[ChatCompletionMessageParam] = [ChatCompletionSystemMessageParam(...), ...]`).

Applied to files:

  • autogpt_platform/backend/backend/data/db_accessors.py
  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/util/workspace_storage_test.py
  • autogpt_platform/backend/backend/util/workspace_storage.py
  • autogpt_platform/backend/backend/data/workspace_folder_test.py
  • autogpt_platform/backend/backend/util/workspace.py
  • autogpt_platform/backend/backend/data/db_manager.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/data/workspace_folder.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/data/workspace.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
  • autogpt_platform/backend/backend/api/features/workspace/folder_routes.py
📚 Learning: 2026-07-21T15:48:34.754Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 13627
File: docs/integrations/block-integrations/llm.md:68-68
Timestamp: 2026-07-21T15:48:34.754Z
Learning: Files under docs/integrations/block-integrations/*.md are generated by autogpt_platform/backend/scripts/generate_block_docs.py. If reviewing a documentation-content change, do it by updating the generator’s authoritative source declarations and regenerate the markdown (or use the generator) rather than making unrelated direct edits to the generated Markdown. CI uses the generator’s --check mode to enforce synchronization, so the generated output must match what the generator produces.

Applied to files:

  • docs/integrations/block-integrations/misc.md
📚 Learning: 2026-03-01T07:58:56.207Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/api/openapi.json:10030-10037
Timestamp: 2026-03-01T07:58:56.207Z
Learning: When a backend field represents sensitive data, use a secret type (e.g., Pydantic SecretStr with length constraints) so OpenAPI marks it as a password/writeOnly field. Apply this pattern to similar sensitive request fields across API schemas so generated TypeScript clients and docs treat them as secrets and do not mishandle sensitivity. Review all openapi.jsons where sensitive inputs are defined and replace plain strings with SecretStr-like semantics with appropriate minLength constraints.

Applied to files:

  • autogpt_platform/frontend/src/app/api/openapi.json
📚 Learning: 2026-04-14T06:39:49.111Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12773
File: autogpt_platform/frontend/src/app/api/openapi.json:12803-12806
Timestamp: 2026-04-14T06:39:49.111Z
Learning: In OpenAPI specs, ensure the schema/message length caps for the StreamChatRequest.message and QueuePendingMessageRequest.message fields are set to the intended values: StreamChatRequest.message maxLength must be 64000 and QueuePendingMessageRequest.message maxLength must be 32000. Keep QueuePendingMessageRequest.message consistent with PendingMessage.content, and ensure the pending (queue) ceiling never exceeds the stream ceiling because both ultimately feed the same LLM context window. Update any legacy smaller limits (e.g., 4000/16000) to these newer ceilings.

Applied to files:

  • autogpt_platform/frontend/src/app/api/openapi.json
📚 Learning: 2026-03-07T07:43:09.871Z
Learnt from: kcze
Repo: Significant-Gravitas/AutoGPT PR: 12328
File: autogpt_platform/frontend/src/app/api/openapi.json:1116-1118
Timestamp: 2026-03-07T07:43:09.871Z
Learning: For autogpt_platform/frontend/src/app/api/openapi.json, preserve the existing behavior: HTTPBearerJWT is declared at the router level with Depends(auth.get_user_id) returning None for unauthenticated users; treat as optional auth. Do not change per-operation security descriptions unless you plan a repo-wide OpenAPI update. If you change this file, prefer clarifying operation descriptions rather than altering security requirements.

Applied to files:

  • autogpt_platform/frontend/src/app/api/openapi.json
📚 Learning: 2026-03-04T08:04:35.881Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12273
File: autogpt_platform/backend/backend/copilot/tools/workspace_files.py:216-220
Timestamp: 2026-03-04T08:04:35.881Z
Learning: In the AutoGPT Copilot backend, ensure that SVG images are not treated as vision image types by excluding 'image/svg+xml' from INLINEABLE_MIME_TYPES and MULTIMODAL_TYPES in tool_adapter.py; the Claude API supports PNG, JPEG, GIF, and WebP for vision. SVGs (XML text) should be handled via the text path instead, not the vision path.

Applied to files:

  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
📚 Learning: 2026-04-01T04:17:41.600Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12632
File: autogpt_platform/backend/backend/copilot/tools/workspace_files.py:0-0
Timestamp: 2026-04-01T04:17:41.600Z
Learning: When reviewing AutoGPT Copilot tool implementations, accept that `readOnlyHint=True` (provided via `ToolAnnotations`) may be applied unconditionally to *all* tools—even tools that have side effects (e.g., `bash_exec`, `write_workspace_file`, or other write/save operations). Do **not** flag these tools for having `readOnlyHint=True`; this is intentional to enable fully-parallel dispatch by the Anthropic SDK/CLI and has been E2E validated. Only flag `readOnlyHint` issues if they conflict with the established `ToolAnnotations` behavior (e.g., missing/incorrect propagation relative to the intended annotation mechanism).

Applied to files:

  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
📚 Learning: 2026-06-06T12:22:37.648Z
Learnt from: anvyle
Repo: Significant-Gravitas/AutoGPT PR: 13302
File: autogpt_platform/backend/backend/copilot/tools/agent_search.py:579-583
Timestamp: 2026-06-06T12:22:37.648Z
Learning: When writing LLM-facing instruction strings that trigger tool calls in this AutoGPT codebase, use the exact registered tool name `view_agent_output` (as defined in `backend/copilot/tools/agent_output.py` via its `name` property and exported via `TOOL_REGISTRY`). Do not reference the bare name `agent_output`, since it is not a valid tool name and will cause tool invocation to fail.

Applied to files:

  • autogpt_platform/backend/backend/copilot/prompting.py
  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/copilot/permissions.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
📚 Learning: 2026-03-04T12:19:39.243Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12279
File: autogpt_platform/backend/backend/copilot/tools/base.py:184-188
Timestamp: 2026-03-04T12:19:39.243Z
Learning: In autogpt_platform/backend/backend/copilot/tools/, ensure that anonymous users always pass user_id=None to tool execution methods. The anon_ prefix (e.g., anon_123) is used only for PostHog/analytics distinct_id and must not be used as an actual user_id. Use a simple truthiness check on user_id (e.g., if user_id: ... else: ... or a dedicated is_authenticated flag) to distinguish anonymous from authenticated users, and review all tool execution call sites within this directory to prevent accidentally forwarding an anon_ user_id to tools.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
📚 Learning: 2026-03-31T14:22:26.566Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12622
File: autogpt_platform/backend/backend/copilot/tools/agent_search.py:223-236
Timestamp: 2026-03-31T14:22:26.566Z
Learning: In files under autogpt_platform/backend/backend/copilot/tools/, ensure agent graph enrichment uses the typed Pydantic model `backend.data.graph.Graph` for `AgentInfo.graph` (i.e., `Graph | None`), not `dict[str, Any]`. When enriching with graph data (e.g., `_enrich_agents_with_graph`), prefer calling `graph_db().get_graph(graph_id, version=None, user_id=user_id)` directly to retrieve the typed `Graph` object rather than routing through JSON conversions like `get_agent_as_json()` / `graph_to_json()`.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
  • autogpt_platform/backend/backend/copilot/tools/__init__.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py
  • autogpt_platform/backend/backend/copilot/tools/models.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py
🔇 Additional comments (25)
autogpt_platform/backend/backend/copilot/tools/workspace_files.py (1)

864-869: LGTM!

autogpt_platform/backend/backend/copilot/tools/workspace_files_test.py (1)

6-13: LGTM!

Also applies to: 927-940, 942-986

autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py (1)

100-109: LGTM!

autogpt_platform/frontend/src/app/api/openapi.json (1)

20775-20780: LGTM!

docs/integrations/block-integrations/misc.md (1)

61-61: 📐 Maintainability & Code Quality

Verify this generated documentation was regenerated from its source declaration.

Update the authoritative AutoPilot tool declaration and run the documentation generator’s --check mode; otherwise this Markdown change can be overwritten or rejected by CI.

Based on learnings, files under docs/integrations/block-integrations/ are generated and must remain synchronized with autogpt_platform/backend/scripts/generate_block_docs.py.

Source: Learnings

autogpt_platform/backend/backend/data/db_accessors.py (1)

134-146: LGTM!

autogpt_platform/backend/backend/data/db_manager.py (1)

152-160: LGTM!

Also applies to: 416-422, 708-714

autogpt_platform/backend/backend/data/workspace_folder.py (1)

103-273: LGTM!

autogpt_platform/backend/backend/api/features/workspace/folder_routes.py (1)

17-19: LGTM!

Also applies to: 52-57, 67-76, 88-99, 109-117, 125-134

autogpt_platform/backend/backend/api/features/workspace/folder_routes_test.py (1)

85-227: LGTM!

autogpt_platform/backend/backend/copilot/tools/models.py (1)

79-86: LGTM!

Also applies to: 372-385

autogpt_platform/backend/backend/copilot/tools/workspace_folders_test.py (1)

1-334: LGTM!

autogpt_platform/backend/backend/util/workspace_storage.py (3)

88-109: LGTM!


222-254: 🗄️ Data Integrity & Integration

Verified: GCS server-side copy correctly forwards custom metadata.

Confirmed against the gcloud-aio-storage library source that Storage.copy()'s metadata kwarg is treated as the destination object resource body, where custom metadata must be nested under an inner "metadata" key — exactly what this code does. No discrepancy with store()'s flat metadata= usage in upload(), since that call takes a different (flatter) shape by design.


392-413: LGTM!

autogpt_platform/backend/backend/util/workspace_storage_test.py (1)

48-99: LGTM!

autogpt_platform/backend/backend/util/workspace_transfer.py (1)

92-174: LGTM on the rest of copy_file's flow (quota check ordering, blob cleanup on DB failure, self-copy rejection).

autogpt_platform/backend/backend/util/workspace.py (1)

445-476: LGTM!

autogpt_platform/backend/backend/util/workspace_transfer_test.py (1)

1-335: LGTM!

autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py (2)

79-139: LGTM!


141-299: LGTM!

autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer_test.py (1)

1-264: LGTM!

autogpt_platform/backend/backend/copilot/permissions.py (1)

80-92: LGTM!

Also applies to: 111-119

autogpt_platform/backend/backend/copilot/tools/__init__.py (1)

60-72: LGTM!

Also applies to: 161-167

autogpt_platform/backend/backend/copilot/prompting.py (1)

495-515: LGTM!

Comment thread autogpt_platform/backend/backend/copilot/tools/workspace_files.py Outdated
Comment thread autogpt_platform/backend/backend/util/workspace_transfer.py
move_workspace_file and copy_workspace_file accepted a caller-supplied
folder_id and passed it straight through to the write, unlike the sibling
move_workspace_files_to_folder tool which verifies the folder belongs to
the workspace. A foreign or stale folder_id could mis-file the file or
surface as a raw foreign-key error.

Validate folder_id against the workspace before writing and return a clean
"folder not found" message instead.

@autogpt-pr-reviewer autogpt-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📋 Automated Review — PR #13700

PR #13700 — feat(backend): add workspace file move/copy and workspace folder tools
Author: Abhi1992002 | Files: 25

🎯 Verdict: APPROVE (with Should-Fix items — no traced blockers)

PR Description Quality

✅ Has Why + What + How — the description explains the motivation (replace the read→write→delete relocation anti-pattern), enumerates the six new CoPilot tools, and documents the server-side move (metadata-only) / copy (storage copy()) design plus the truncation-error fix. Author's checklist is fully ticked with a note that DB-backed suites run only in CI.

What This PR Does

Adds six new CoPilot workspace tools — move/copy a file and create/delete/list/bulk-move-to workspace folders — so an agent can relocate or duplicate a file in a single call instead of downloading, re-uploading, and deleting it (which pulled the whole file through model context and process memory). Move is now a pure DB metadata rewrite and copy delegates to native GCS server-side blob copy (or off-loop shutil.copyfile locally), so bytes never transit the process. It also fixes a misleading "truncated" error on write_workspace_file when a filename was simply missing.

Specialist Findings

🛡️ Security ✅ — Skills-registry ACL is solid (raw path and resolved file_info.path are re-checked; get_workspace_manager is always session-scoped so a destination can't resolve to the real registry). Cross-workspace DB writes correctly use update_many guarded on workspaceId + isDeleted, not PK-only update. The one gap it raised — unvalidated folder_id on move/copy (workspace_transfer.py:61,158) — was already fixed in follow-up commit 87c70f33 (_validate_folder now guards both paths), confirmed by the discussion reviewer and a clean CodeRabbit re-review. No active security blocker.

🏗️ Architecture ⚠️ — Clean layering: transfer logic extracted into util/workspace_transfer.py, storage-backend copy() abstraction is the right level, RPC folder-function renames are well-motivated.
🟠 FolderAlreadyExistsError (copilot/tools/workspace_folders.py:163) is not in the RPC EXCEPTION_MAPPING (util/service.py:231-234), so on the DatabaseManager RPC path a duplicate-name create is re-raised as HTTPClientError and the actionable "already exists" guidance is lost (still returns an error — graceful degradation, not a crash).

Performance ✅ — Net win: eliminates full-file transfers in favor of O(1) metadata writes / one blob-copy API call, cost independent of file size in-process. No N+1, no blocking I/O on the event loop (local copy uses asyncio.to_thread). Only minor redundant-query optimizations on non-default paths.

🧪 Testing ⚠️ — Unusually thorough suite (73 tests, mutation-checked, meaningful assertions). Gaps: the security-critical update_workspace_file_location scoping function (data/workspace.py:370) is fully mocked in every test — its update_many workspace guard is never exercised — and the _check_quota overwrite branch (workspace_transfer.py:213) is untested.

📖 Quality ✅ — Clean, well-documented, good module split. Minor: cross-module private imports (_resolve_file et al. from workspace_files) and a stale docstring referencing a non-existent parentId field (models.py:377).

📦 Product ⚠️ — Feature complete and end-to-end wired. Two agent-facing reporting bugs: a folder-only move reports "nothing to do" even though folder membership changed (workspace_file_transfer.py:205), and a bulk move where every ID is foreign reports success with "Moved 0 file(s)" (workspace_folders.py:440).

📬 Discussion ⚠️ — No human review yet; top bot finding (folder ownership) fixed in 87c70f33. Three lower-severity bot findings remain unacknowledged: Sentry MEDIUM (bulk-move defaults to root when no destination given, workspace_folders.py:412), CodeRabbit truncation truthiness (workspace_files.py:848), Sentry LOW TOCTOU quota race.

🔎 QA ✅ — Exercised all six tools against the real backend in Docker: 16/16 scenarios passed, including move-is-metadata-only (storage_unchanged=True), byte-identical copy (CONTENT MATCH: True), collision/overwrite/self-copy/skills-registry guards, foreign-ID reporting, and the truncation fix. 113 tests passed including the DB-backed round-trips the author couldn't run locally. Services logged no errors.

🟠 Should Fix

  1. RPC exception not reconstructed (copilot/tools/workspace_folders.py:163) — register FolderAlreadyExistsError in EXCEPTION_MAPPING (or translate at the accessor boundary) so the actionable duplicate-name message survives the DatabaseManager RPC path; add a test on that path. (Flagged by: architect)
  2. Folder-only move mislabeled as no-op (workspace_file_transfer.py:205) — the success message branches only on path equality; a same-path move that changes folder_id is applied but reported as "nothing to do." Include folder change in the no-op check. (Flagged by: product)
  3. Bulk move reports success on zero moves (workspace_folders.py:440) — return an ErrorResponse when len(moved_ids) == 0 instead of a success response. Same theme as the Sentry MEDIUM about defaulting to root with no destination (:412). (Flagged by: product, discussion — 2 specialists)
  4. No direct test for update_workspace_file_location (data/workspace.py:370) — add a mocker-based test (mirroring workspace_folder_test.py, no Docker needed) asserting the update_many where-clause includes workspaceId + isDeleted, that path is leading-slash-normalized, and that updated_count==0 returns None. This is the function carrying the multi-tenant scoping guarantee. (Flagged by: testing)
  5. Quota-overwrite branch untested (workspace_transfer.py:213) — add a copy test with overwrite=True near the quota ceiling that succeeds only once the occupant's size is subtracted. (Flagged by: testing)
  6. Missing-filename truthiness check (workspace_files.py:848) — presence should use is not None, else a legitimate content="" is misclassified as no-args. (Flagged by: discussion/CodeRabbit)

🟡 Nice to Have

  1. _resolve_folder by-ID does a full list + count aggregation (workspace_folders.py:86) — use the existing targeted get_workspace_folder(folder_id, workspace_id) for the ID branch. (performance)
  2. Redundant destination lookup on overwrite-copy (workspace_transfer.py:135) — resolve the occupant once, thread into both quota and clear. (performance)
  3. Duplicated workspace://<id>#<mime> builder (workspace_file_transfer.py:280 vs workspace_files.py:942) — extract one helper. (architect, quality — 2 specialists)
  4. format_bytes lazy import cycle (workspace_transfer.py:221) — relocate to a lower-level util to break the bidirectional dependency. (architect)
  5. Cross-module private imports (workspace_file_transfer.py:21) — promote shared _-prefixed symbols to public/shared surface. (quality, architect — 2 specialists)
  6. move_workspace_file cannot clear folder to root (workspace_file_transfer.py:195) — None means "keep" here but "root" elsewhere; clarify or support explicit root. (product)

🔵 Nits

  1. Stale parentId docstring (copilot/tools/models.py:377) — WorkspaceFolderInfoData has no such field; drop the clause. (quality)
  2. Vacuous download.assert_not_called() (workspace_storage_test.py:99) — copy() never calls it, so the assertion is always true; assert against the real client method instead. (testing)
  3. Mime normalization inconsistencycopy returns lowercased mime, move returns raw (workspace_file_transfer.py:291 vs :210). (architect)

QA Screenshots

Screenshot Description
artifacts page with workspace folders Artifacts page rendering real tool outputs — renamed.txt (move), copy.txt/dup.txt (copy), and Receipts/Reports folders ✅

Human Review Needed

YES — This modifies the multi-tenant authorization boundary (the workspace-scoped update_many guard in update_workspace_file_location), and that scoping function currently has no direct test. A human familiar with the workspace ACL model should confirm the cross-workspace guarantees before merge.

Risk Assessment

Merge risk: LOW | Rollback: EASY — additive tooling behind CoPilot tool registration; move/copy are metadata/storage-API operations with no schema migration in the critical path.

CI Status

Local harness: ✅ frontend lint, ✅ backend lint, ✅ frontend typecheck, ✅ build. ⚠️ frontend test:unit failed in the local sandbox — this is a backend PR with no substantive frontend changes, so this is environment skew, not a code defect (the repo's real suite for these changes is the backend/QA path, where 113 tests passed).
GitHub CI: per discussion reviewer, 20/28 checks green, 6 still running (integration/e2e/py-version matrix), 0 failing, no merge conflicts, Codecov patch 92.98%. Live status not independently re-fetched at synthesis time — treat as in-progress, not final.


UI Testing — Variant Results

✅ local: All six new workspace move/copy/folder tools and the truncation-error fix work end-to-end with correct positive/negative behavior; 113 tests pass and no runtime errors observed.

✅ hosted: All six new workspace move/copy/folder tools and the missing-filename fix work end-to-end against the live DB, storage backend, and UI, with 286 passing tests and correct negative/ACL handling.

Comment thread autogpt_platform/backend/backend/util/workspace_transfer.py
Comment thread autogpt_platform/backend/backend/util/workspace_transfer.py
Comment thread autogpt_platform/backend/backend/util/workspace_transfer.py
Comment thread autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
Comment thread autogpt_platform/backend/backend/util/workspace_transfer.py
Comment thread autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
Comment thread autogpt_platform/backend/backend/copilot/tools/workspace_files.py Outdated
Comment thread autogpt_platform/backend/backend/util/workspace_transfer.py
- move_workspace_files_to_folder now requires an explicit destination
  (folder or to_root) instead of silently moving to root, and returns an
  error when none of the given file IDs were in the workspace.
- move_workspace_file no longer reports "nothing to do" when only the
  folder membership changed (path unchanged).
- write_workspace_file detects supplied arguments by presence (is not None)
  so an explicit empty content="" is no longer misread as a truncated call.
- Add direct scoping tests for update_workspace_file_location and a
  quota test for the overwrite-copy branch.
@Abhi1992002

Copy link
Copy Markdown
Member Author

Thanks for the thorough review. Summary of how the feedback was handled:

Fixed

  • folder_id ownership (move/copy)move_workspace_file/copy_workspace_file now validate folder_id against the caller's workspace before writing (_validate_folder in workspace_transfer.py, commit 87c70f3), matching the sibling folder tool.
  • move_workspace_files_to_folder — now requires an explicit destination (folder or to_root) instead of silently moving to root, and returns an error when none of the given file IDs were in the workspace (560448f).
  • Move no-op message — no longer reports "nothing to do" when only folder membership changed (560448f).
  • write_workspace_file arg detection — uses is not None so an explicit empty content="" is no longer misread as a truncated call (560448f).
  • Test coverage — added direct scoping tests for update_workspace_file_location (data/workspace_test.py) and a quota test for the overwrite-copy branch (560448f).

Acknowledged / deferred (low-severity, deliberate design or out-of-scope polish; noted inline on each thread):

  • Copy skips re-scan by documented "all ingress is scanned" invariant.
  • Best-effort quota enforcement (small TOCTOU window, consistent with write_file).
  • workspace://<id> is an internal reference resolved by the frontend, not an HTTP link.
  • Same-package extraction touching WorkspaceManager._resolve_path/shared helpers, format_bytes lazy import, minor DRY/perf items — reasonable follow-ups.
  • RPC exception-mapping for FolderAlreadyExistsError (generic-but-actionable error over the RPC path) — follow-up.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

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

Inline comments:
In `@autogpt_platform/backend/backend/data/workspace_test.py`:
- Around line 41-64: Update the test around update_workspace_file_location and
its mocked _file_record to set folderId to "fld-9", then assert the returned
result has folder_id equal to "fld-9" alongside the existing path assertion.

In `@autogpt_platform/backend/backend/util/workspace_transfer_test.py`:
- Around line 343-346: Combine the nested context managers in the test using a
single with statement that manages both _patched and
patch.object(WorkspaceManager, "delete_file", ...), preserving their existing
scopes and mock behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ab0c205e-b28b-460a-81ca-828ec5fea2f9

📥 Commits

Reviewing files that changed from the base of the PR and between 87c70f3 and 560448f.

📒 Files selected for processing (5)
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • autogpt_platform/backend/backend/copilot/tools/workspace_files.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_file_transfer.py
  • autogpt_platform/backend/backend/copilot/tools/workspace_folders.py
📜 Review details
⏰ Context from checks skipped due to timeout. (18)
  • GitHub Check: check API types
  • GitHub Check: lint
  • GitHub Check: integration_test
  • GitHub Check: Seer Code Review
  • GitHub Check: type-check (3.12)
  • GitHub Check: test (3.12)
  • GitHub Check: type-check (3.13)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: type-check (3.11)
  • GitHub Check: lint
  • GitHub Check: end-to-end tests
  • GitHub Check: check-docs-sync
  • GitHub Check: types
  • GitHub Check: lint
  • GitHub Check: Analyze (typescript)
  • GitHub Check: Analyze (python)
  • GitHub Check: Check PR Status
🧰 Additional context used
📓 Path-based instructions (5)
autogpt_platform/backend/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/backend/**/*.py: Use Python 3.11 (required; managed by Poetry via pyproject.toml) for backend development
Always run 'poetry run format' (Black + isort) before linting in backend development
Always run 'poetry run lint' (ruff) after formatting in backend development

autogpt_platform/backend/**/*.py: Use poetry run ... command for executing Python package dependencies
Use top-level imports only — avoid local/inner imports except for lazy imports of heavy optional dependencies like openpyxl
Use absolute imports with from backend.module import ... for cross-package imports; single-dot relative imports are acceptable for sibling modules within the same package; avoid double-dot relative imports
Do not use duck typing — avoid hasattr/getattr/isinstance for type dispatch; use typed interfaces/unions/protocols instead
Use Pydantic models over dataclass/namedtuple/dict for structured data
Do not use linter suppressors — no # type: ignore, # noqa, # pyright: ignore; fix the type/code instead
Prefer list comprehensions over manual loop-and-append patterns
Use early return with guard clauses first to avoid deep nesting
Use %s for deferred interpolation in debug log statements for efficiency; use f-strings elsewhere for readability (e.g., logger.debug("Processing %s items", count) vs logger.info(f"Processing {count} items"))
Sanitize error paths by using os.path.basename() in error messages to avoid leaking directory structure
Be aware of TOCTOU (Time-Of-Check-Time-Of-Use) issues — avoid check-then-act patterns for file access and credit charging
Use transaction=True for Redis pipelines to ensure atomicity on multi-step operations
Use max(0, value) guards for computed values that should never be negative
Keep files under ~300 lines; if a file grows beyond this, split by responsibility (extract helpers, models, or a sub-module into a new file)
Keep functions under ~40 lines; extract named helpers when a function grows longer
...

Files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
autogpt_platform/backend/backend/data/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

All data access in backend requires user ID checks; verify this for any 'data/*.py' changes

Files:

  • autogpt_platform/backend/backend/data/workspace_test.py
autogpt_platform/{backend,autogpt_libs}/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_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/workspace_test.py
autogpt_platform/backend/**/*_test.py

📄 CodeRabbit inference engine (autogpt_platform/backend/AGENTS.md)

autogpt_platform/backend/**/*_test.py: Use pytest with snapshot testing for API responses
Colocate test files with source files using *_test.py naming convention
Mock at boundaries — mock where the symbol is used, not where it's defined; after refactoring, update mock targets to match new module paths
Use AsyncMock from unittest.mock for async functions in tests
When writing tests, use Test-Driven Development (TDD): write failing tests marked with @pytest.mark.xfail before implementation, then remove the marker once the implementation is complete
When creating snapshots in tests, use poetry run pytest path/to/test.py --snapshot-update; always review snapshot changes with git diff before committing

Files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
🧠 Learnings (13)
📚 Learning: 2026-02-26T17:02:22.448Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12211
File: .pre-commit-config.yaml:160-179
Timestamp: 2026-02-26T17:02:22.448Z
Learning: Keep the pre-commit hook pattern broad for autogpt_platform/backend to ensure OpenAPI schema changes are captured. Do not narrow to backend/api/ alone, since the generated schema depends on Pydantic models across multiple directories (backend/data/, backend/blocks/, backend/copilot/, backend/integrations/, backend/util/). Narrowing could miss schema changes and cause frontend type desynchronization.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
📚 Learning: 2026-03-05T15:42:08.207Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12297
File: .claude/skills/backend-check/SKILL.md:14-16
Timestamp: 2026-03-05T15:42:08.207Z
Learning: In Python files under autogpt_platform/backend (recursively), rely on poetry run format to perform formatting (Black + isort) and linting (ruff). Do not run poetry run lint as a separate step after poetry run format, since format already includes linting checks.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
📚 Learning: 2026-03-16T16:35:40.236Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12440
File: autogpt_platform/backend/backend/api/features/workflow_import.py:54-63
Timestamp: 2026-03-16T16:35:40.236Z
Learning: Avoid using the word 'competitor' in public-facing identifiers and text. Use neutral naming for API paths, model names, function names, and UI text. Examples: rename 'CompetitorFormat' to 'SourcePlatform', 'convert_competitor_workflow' to 'convert_workflow', '/competitor-workflow' to '/workflow'. Apply this guideline to files under autogpt_platform/backend and autogpt_platform/frontend.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
📚 Learning: 2026-03-31T15:37:38.626Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12623
File: autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer.py:37-47
Timestamp: 2026-03-31T15:37:38.626Z
Learning: When validating/constructing Anthropic API model IDs in Significant-Gravitas/AutoGPT, allow the hyphen-separated Claude Opus 4.6 model ID `claude-opus-4-6` (it corresponds to `LlmModel.CLAUDE_4_6_OPUS` in `autogpt_platform/backend/backend/blocks/llm.py`). Do NOT require the dot-separated form in Anthropic contexts. Only OpenRouter routing variants should use the dot separator (e.g., `anthropic/claude-opus-4.6`); `claude-opus-4-6` should be treated as correct when passed to Anthropic, and flagged only if it’s used in the OpenRouter path where the dot form is expected.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
📚 Learning: 2026-04-15T02:43:36.890Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12780
File: autogpt_platform/backend/backend/copilot/tools/workspace_files.py:0-0
Timestamp: 2026-04-15T02:43:36.890Z
Learning: When reviewing Python exception handlers, do not flag `isinstance(e, X)` checks as dead/unreachable if the caught exception `X` is a subclass of the exception type being handled. For example, if `X` (e.g., `VirusScanError`) inherits from `ValueError` (directly or via an intermediate class) and it can be raised within an `except ValueError:` block, then `isinstance(e, X)` inside that handler is reachable and should not be treated as dead code.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
📚 Learning: 2026-05-23T05:29:43.085Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 13200
File: autogpt_platform/backend/backend/executor/scheduler.py:590-593
Timestamp: 2026-05-23T05:29:43.085Z
Learning: When reviewing Python code that uses Pydantic discriminated/tagged unions (e.g., `Annotated[Union[...], Field(discriminator="kind")]`), recognize that using `isinstance(x, SomeVariantInfo)` to narrow the union is an intentional and correct runtime guard and should also enable static type narrowing in tools like Pyright. Do not recommend replacing such `isinstance`-based narrowing with `cast(...)` when the check already proves the variant at runtime.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
📚 Learning: 2026-04-21T04:35:34.710Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12865
File: autogpt_platform/backend/backend/data/credit.py:1584-1584
Timestamp: 2026-04-21T04:35:34.710Z
Learning: When reviewing this codebase, don’t flag snake_case attribute names (e.g., `subscription_tier`, `stripe_customer_id`, `top_up_config`) on the app-layer Pydantic `User` model as “wrong” field names. These are correct for the app-layer model and are expected to be mapped from the Prisma-layer camelCase fields (e.g., `subscriptionTier`, `stripeCustomerId`) inside methods like `User.from_db()`. Only Prisma-returned/raw objects would use camelCase, but functions like `get_user_by_id(user_id: str)` are expected to return the Pydantic app-layer model.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
📚 Learning: 2026-05-07T15:32:39.703Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 13033
File: autogpt_platform/backend/backend/data/generate_data.py:111-117
Timestamp: 2026-05-07T15:32:39.703Z
Learning: When reviewing the Python data-generation layer, do not treat missing `user_id`/user filtering in calls to graph-metadata resolvers as a security issue if the `graph_id` inputs are already guaranteed to be user-scoped by earlier upstream SQL (e.g., `WHERE "userId" = ...`). In particular, `_resolve_agent_name(graph_id)` in `generate_data.py` correctly calls `get_graph_metadata(graph_id=graph_id)` without a `user_id` parameter by design, because name resolution must also work for user-executed shared/marketplace agents that the user may not own.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
📚 Learning: 2026-04-22T11:46:04.431Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12881
File: autogpt_platform/backend/backend/copilot/config.py:0-0
Timestamp: 2026-04-22T11:46:04.431Z
Learning: Do not flag the Claude Sonnet 4.6 model ID as incorrect when it uses the project’s established hyphenated convention: `anthropic/claude-sonnet-4-6`. This hyphen form is the intentional, production convention and should be treated as valid (including in files like llm.py, blocks tests, reasoning.py, `_is_anthropic_model` tests, and config defaults). Note that OpenRouter also accepts the dot variant `anthropic/claude-sonnet-4.6`, so either form may be tolerated, but `anthropic/claude-sonnet-4-6` should be considered the standard to match project usage.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
📚 Learning: 2026-04-22T11:46:12.892Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12881
File: autogpt_platform/backend/backend/copilot/baseline/service.py:322-332
Timestamp: 2026-04-22T11:46:12.892Z
Learning: In this codebase (Significant-Gravitas/AutoGPT), OpenRouter-routed Anthropic model IDs should use the hyphen-separated convention (e.g., `anthropic/claude-sonnet-4-6`, `anthropic/claude-opus-4-6`). Although OpenRouter may accept both hyphen and dot variants, treat the hyphen-separated form as the intended, correct codebase-wide convention and do not flag it as an error. Only flag the dot-separated variant (e.g., `anthropic/claude-sonnet-4.6`) as incorrect when reviewing/validating model ID strings for OpenRouter-routed Anthropic models.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
📚 Learning: 2026-05-07T18:48:14.242Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 13040
File: autogpt_platform/backend/backend/blocks/llm.py:0-0
Timestamp: 2026-05-07T18:48:14.242Z
Learning: In this repository, isort may split imports from the same module into separate blocks when some imports are aliased (e.g., `from module import X as Y`) and others are not. Preserve the two-block layout when it results from isort (such as keeping `from openai.types.chat import ChatCompletion as OpenAIChatCompletion` separate from non-aliased imports from `openai.types.chat`). Do not treat that split as a style issue during review; merging them into a single block can fail CI with `Imports are incorrectly sorted and/or formatted`.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
📚 Learning: 2026-05-26T14:24:34.866Z
Learnt from: Abhi1992002
Repo: Significant-Gravitas/AutoGPT PR: 13217
File: autogpt_platform/backend/backend/api/features/search/service.py:137-137
Timestamp: 2026-05-26T14:24:34.866Z
Learning: In the Significant-Gravitas/AutoGPT backend, treat `user_id` (an opaque UUID used only for correlation/tracing) as non-PII. Do not flag direct logging of `user_id` in `logger.warning`/`logger.info` statements as a PII exposure issue, as the established convention is to log `user_id` for tracing while reserving PII for fields like email or display name.

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
📚 Learning: 2026-06-11T19:39:10.493Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 13337
File: autogpt_platform/backend/backend/copilot/graphiti/reranker.py:0-0
Timestamp: 2026-06-11T19:39:10.493Z
Learning: In the Significant-Gravitas/AutoGPT Python backend, when calling the OpenAI Python client `chat.completions.create`, construct the `messages` payload using the concrete typed-dict variants from `openai.types.chat` (e.g., `ChatCompletionSystemMessageParam`, `ChatCompletionUserMessageParam`, etc.) rather than trying to instantiate `ChatCompletionMessageParam` directly. `ChatCompletionMessageParam` is a `Union` alias and is not constructible, so `ChatCompletionMessageParam(role=..., content=...)` should fail type checking. Build each message element with the appropriate concrete typed dict and then annotate the resulting list as `list[ChatCompletionMessageParam]` (e.g., `messages: list[ChatCompletionMessageParam] = [ChatCompletionSystemMessageParam(...), ...]`).

Applied to files:

  • autogpt_platform/backend/backend/data/workspace_test.py
  • autogpt_platform/backend/backend/util/workspace_transfer_test.py
🪛 Ruff (0.16.0)
autogpt_platform/backend/backend/util/workspace_transfer_test.py

[warning] 343-346: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

🔇 Additional comments (2)
autogpt_platform/backend/backend/data/workspace_test.py (2)

1-33: LGTM!


67-86: LGTM!

Comment thread autogpt_platform/backend/backend/data/workspace_test.py Outdated
Comment thread autogpt_platform/backend/backend/util/workspace_transfer_test.py
Comment thread autogpt_platform/backend/backend/util/workspace_storage.py
Strengthen test_update_location_is_scoped_to_the_workspace so the mocked
row carries the new folderId and the test asserts the returned model's
folder_id, not just the path.
@Abhi1992002

Copy link
Copy Markdown
Member Author

!deploy

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deploying PR #13700 to development environment...

@Pwuts

Pwuts commented Jul 29, 2026

Copy link
Copy Markdown
Member

Preview environment is live (all services healthy)

  • Deployed: 9b7dbd7c59901d42c28e7ab034af4b0b6cf1251f at 2026-07-29 11:42 UTC
  • Database: isolated Supabase branch pr-13700 (state persists across redeploys unless migration drift forces a reset)
  • URLs: posted in the team Discord

Push more commits, then comment !deploy to update · !undeploy or close the PR to tear down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: signed CLA signed by all contributors documentation Improvements or additions to documentation platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end size/xl

Projects

Status: 🆕 Needs initial review
Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants