Skip to content

feat(backend/copilot): inline picker-backed inputs via run_block + accept AgentInputBlock subclasses - #12880

Merged
majdyz merged 22 commits into
devfrom
fix/copilot-drive-file-validator
Apr 24, 2026
Merged

feat(backend/copilot): inline picker-backed inputs via run_block + accept AgentInputBlock subclasses#12880
majdyz merged 22 commits into
devfrom
fix/copilot-drive-file-validator

Conversation

@anvyle

@anvyle anvyle commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Why / What / How

Why: Resolves #12875. CoPilot's agent-builder was hardcoding Google Drive file IDs into consuming blocks' input_default instead of wiring an AgentGoogleDriveFileInputBlock. A beta user hit this across 13 saved versions of one agent. Root causes:

  1. validate_io_blocks only accepted the literal base AgentInputBlock / AgentOutputBlock IDs, so even when CoPilot used a specialized subclass like AgentGoogleDriveFileInputBlock as the only input, the validator forced it to keep a throwaway base alongside — entrenching the anti-pattern.
  2. Running a Drive consumer directly via CoPilot's run_block silently failed because the auto-credentials flow (picker attaches _credentials_id) existed only in the graph executor, never in CoPilot's direct-execution path.
  3. Drive picker guidance lived in agent_generation_guide.md instead of on the blocks themselves, so it duplicated and drifted from the code.
  4. Observed in a live session: when asked to read a private sheet, CoPilot refused with "share publicly or use the builder" instead of calling run_block and letting the picker render — the prompt rule was buried and the fallback path (omitted required picker field) returned a generic schema preview.

What: Four coordinated platform + CoPilot improvements. No block-specific validator rules, no Drive-specific code in UI or prompt.

How:

1. validate_io_blocks subclass support

Accepts any block with uiType == "Input" / "Output" (populated from Block.block_type at registration). AgentGoogleDriveFileInputBlock, AgentDropdownInputBlock, AgentTableInputBlock, etc. stand alone. Base-ID fallback preserved for call sites that pass a minimal blocks list.

2. Inline picker via run_block

  • Extracted _acquire_auto_credentials from backend/executor/manager.py into shared backend/executor/auto_credentials.py (exports acquire_auto_credentials + MissingAutoCredentialsError).
  • Wired it into backend/copilot/tools/helpers.py::execute_block. When _credentials_id is present, the block executes with creds injected (chained flows work). When missing/null, execute_block returns the existing SetupRequirementsResponse — frontend's FormRenderer renders the picker inline via the existing GoogleDrivePickerField/GoogleDrivePickerInput. On pick, the LLM re-invokes run_block with the populated input — same continuation pattern as OAuth-missing-credentials. No new response types, no new continuation tool, no new frontend component.
  • run_block now short-circuits to SetupRequirementsResponse when missing required fields include a picker-backed field, skipping the schema-preview round trip the LLM would otherwise take.
  • get_inputs_from_schema spreads the full property schema (**schema) instead of whitelisting — any format / json_schema_extra / custom widget config flows through to the generic custom-field dispatch on the frontend. Future picker formats (date pickers, file pickers, etc.) work without backend changes.
  • Frontend SetupRequirementsCard/helpers.ts uses index-signature passthrough for arbitrary schema keys — no widget-specific code in that layer.

3. validate_only parameter on run_block

run_block(id, {}) is not always a safe probe — for blocks with zero required inputs, it executes. New validate_only: true parameter returns BlockDetailsResponse (schema + missing-input list) without executing, rendering picker cards, or charging credits. Same response shape as the existing schema preview — no new branch, just an extra condition on the existing one. LLM uses this for pre-flight when it's unsure whether a block has required inputs.

4. Block-local picker guidance

Agent-generation picker guidance relocated from the guide onto the blocks themselves — surfaced at find_block time, exactly when the LLM decides to wire a picker-backed consumer:

  • GoogleDriveFileField (shared factory for every Drive field on Sheets/Docs/etc.) appends a standard hint to the caller's description covering: feed from the specialized input block, never hardcode (even one parsed from a URL), picker is the only credential source.
  • AgentGoogleDriveFileInputBlock's block description now covers when it's required, the allowed_views mapping, wiring direction, and a concrete link-shape example.
  • agent_generation_guide.md loses the dedicated 71-line Drive section. The IO-blocks section now tells the LLM specialized subclasses satisfy the requirement and carry their own usage guidance in block/field descriptions — read them when find_block surfaces a match.
  • New "Picker-backed inputs via run_block" section in the CoPilot prompt, written generically (picker fields detected via format / auto_credentials schema hints, no provider names hardcoded) — covers: don't ask the user for URLs/IDs, don't refuse private-resource asks, chained picker objects pass through as-is.
  • Sharpened MissingAutoCredentialsError message so when a bare ID reaches execution, the error explicitly tells the LLM the picker renders inline (not "ask the user for something").

Changes 🏗️

  • backend/copilot/tools/agent_generator/validator.py_collect_io_block_ids + subclass-aware validate_io_blocks.
  • backend/executor/auto_credentials.py (new) — shared acquire_auto_credentials + MissingAutoCredentialsError.
  • backend/executor/manager.py — imports from the shared module, drops the local copy.
  • backend/copilot/tools/helpers.pyexecute_block calls acquire_auto_credentials, merges kwargs, releases locks in finally, returns SetupRequirementsResponse on missing creds. get_inputs_from_schema spreads the full property schema.
  • backend/copilot/tools/run_block.py — picker-field short-circuit + validate_only parameter.
  • backend/copilot/prompting.py — "Picker-backed inputs via run_block" + "Pre-flight with validate_only" sections.
  • backend/blocks/google/_drive.pyGoogleDriveFileField appends the agent-builder hint to every Drive consumer's description.
  • backend/blocks/io.pyAgentGoogleDriveFileInputBlock description expanded.
  • backend/copilot/sdk/agent_generation_guide.md — Drive section removed, IO-blocks subclass note expanded.
  • frontend/.../SetupRequirementsCard/helpers.ts — index-signature passthrough for arbitrary schema keys; schema fields propagate into the generated RJSF schema.
  • Tests: new TestExecuteBlockAutoCredentials (4 cases) + validate_only + picker-short-circuit cases in run_block_test.py; manager_auto_credentials_test.py moved to new import path; 6 new frontend cases in SetupRequirementsCard/__tests__/helpers.test.ts covering schema passthrough.
  • Also: one-line hoist of import secrets in backend/integrations/managed_providers/ayrshare.py — ruff E402 introduced by refactor(platform): migrate Ayrshare to standard managed-credential flow #12883 was blocking our lint post-merge.

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 unit suites: validator_test (48), helpers_test (40), run_block_test (19), manager_auto_credentials_test (15) — all green
    • Frontend SetupRequirementsCard helpers — 75/75 pass (including 6 new passthrough cases)
    • poetry run format (ruff + isort + black) clean on touched files (pre-existing pyright errors in unrelated graphiti_core / StreamEvent / etc. files not introduced by this PR)
    • Live CoPilot chat on dev-builder confirmed the setup card renders custom/google_drive_picker_field for a Drive consumer block called via run_block
    • Live agent-generation confirmed CoPilot creates a subclass-only agent (AgentGoogleDriveFileInputBlockGoogleSheetsReadBlockAgentOutputBlock) with no throwaway base AgentInputBlock

For configuration changes:

  • N/A — no config changes

…tInputBlock subclasses

Resolves #12875.

CoPilot's agent-builder was hardcoding Google Drive file IDs into consuming
blocks' constantInput instead of wiring AgentGoogleDriveFileInputBlock. The
resulting agents either failed schema validation or failed at execution
because no _credentials_id was attached.

Platform-side fixes:
- validate_io_blocks now accepts any block with uiType "Input"/"Output" as
  satisfying the required-IO check, so specialized subclasses like
  AgentGoogleDriveFileInputBlock, AgentDropdownInputBlock, etc. count on
  their own. Previously only the literal base-class IDs passed, forcing
  CoPilot to keep a throwaway AgentInputBlock alongside real inputs.
- New validate_google_drive_file_inputs rule flags hardcoded values on
  fields backed by GoogleDriveFileField (detected via format
  "google-drive-picker" or the auto_credentials marker). The error points
  users to AgentGoogleDriveFileInputBlock with the correct block_id and
  explains the _credentials_id requirement.

Prompt-tuning in agent_generation_guide.md:
- Documents specialized input subclasses as satisfying the IO requirement.
- New section "REQUIRED: AgentGoogleDriveFileInputBlock for Google Drive
  files" teaches the correct pattern: target shape, allowed_views mapping
  (SPREADSHEETS/DOCUMENTS/PRESENTATIONS), detection rules, and a worked
  example for a Sheets-summarizing agent.

Tests: subclass-input acceptance, subclass-output acceptance, and seven
cases covering the Drive anti-pattern validator (hardcoded object, bare
string, linked field, linked-wins-over-default, null default, non-Drive
fields, and the producer's own value exempted).
@anvyle
anvyle requested a review from a team as a code owner April 22, 2026 07:21
@anvyle
anvyle requested review from Bentlybro and kcze and removed request for a team April 22, 2026 07:21
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Apr 22, 2026
@github-actions github-actions Bot added platform/backend AutoGPT Platform - Back end size/xl labels Apr 22, 2026
@coderabbitai

coderabbitai Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Docs add mandatory Google Drive picker input patterns and wiring; validator changes detect IO blocks by registry uiType and enforce Drive-file wiring (no hardcoded IDs); tests updated to cover uiType-based IO detection and Drive-input validation.

Changes

Cohort / File(s) Summary
Documentation
autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
Adds required guidance: use AgentGoogleDriveFileInputBlock for Drive files, GoogleDriveFile runtime shape (id, mimeType, _credentials_id), forbid hardcoded file IDs in input_default, define allowed_views, picker sharing rules, detection heuristics, and example wiring.
Validator Core Logic
autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
Replaces literal-base-id IO detection with registry-driven uiType classification via new _collect_io_block_ids(), changes validate_io_blocks(...) signature to accept blocks, integrates Drive-input anti-pattern checks (picker detection, hardcoded-ID detection) into the validation pipeline.
Validator Tests
autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py
Test helper _make_block(...) accepts optional ui_type; adds tests verifying IO detection works when blocks advertise uiType == "Input"/"Output", plus Drive-input wiring/hardcode cases and related edge cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

platform/blocks, documentation, Review effort 4/5

Suggested reviewers

  • Bentlybro
  • kcze
  • majdyz

Poem

🐇 I hopped through nodes and nudged each wire,
Pickers now wake only when creds require.
No lodged IDs in constants, clean and bright,
I wired the file so runtime shines its light.
Hooray — the agent asks before it bites! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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
Linked Issues check ✅ Passed The PR addresses all major coding requirements from issue #12875: validate_io_blocks now accepts subclasses via uiType check, Google Drive detection logic implemented via schema inspection, and documentation/guidance provided for proper AgentGoogleDriveFileInputBlock usage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #12875: validator enhancements for IO-block subclasses, Google Drive file input validation, documentation, and supporting tests. No unrelated changes detected.
Title check ✅ Passed The title accurately reflects the main changes: validator updates for GoogleDrive file anti-patterns and IO-block subclass acceptance.
Description check ✅ Passed The description comprehensively documents the PR's purpose (fixing Google Drive anti-pattern + accepting IO subclasses), implementation approach, and all changes across backend, frontend, and tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/copilot-drive-file-validator

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 and usage tips.

@github-actions

github-actions Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

🔍 PR Overlap Detection

This check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early.

🔴 Merge Conflicts Detected

The following PRs have been tested and will have merge conflicts if merged after this PR. Consider coordinating with the authors.

  • fix(copilot): prevent 524 timeout on chat deletion by deferring cleanup #12668 (Otto-AGPT · updated 7d ago)

    • autogpt_platform/backend/backend/api/features/library/db.py (5 conflicts, ~67 lines)
    • autogpt_platform/backend/backend/api/features/library/model.py (1 conflict, ~4 lines)
    • autogpt_platform/backend/backend/api/features/subscription_routes_test.py (22 conflicts, ~957 lines)
    • autogpt_platform/backend/backend/api/features/v1.py (10 conflicts, ~205 lines)
    • autogpt_platform/backend/backend/copilot/baseline/service.py (2 conflicts, ~15 lines)
    • autogpt_platform/backend/backend/copilot/model_test.py (1 conflict, ~5 lines)
    • autogpt_platform/backend/backend/copilot/prompting.py (1 conflict, ~5 lines)
    • autogpt_platform/backend/backend/copilot/sdk/service.py (3 conflicts, ~51 lines)
    • autogpt_platform/backend/backend/copilot/sdk/service_helpers_test.py (1 conflict, ~129 lines)
    • autogpt_platform/backend/backend/copilot/transcript.py (1 conflict, ~11 lines)
    • autogpt_platform/backend/backend/data/credit.py (12 conflicts, ~783 lines)
    • autogpt_platform/backend/backend/data/credit_subscription_test.py (24 conflicts, ~1633 lines)
    • autogpt_platform/frontend/src/app/(platform)/copilot/components/PulseChips/usePulseChips.ts (1 conflict, ~13 lines)
    • autogpt_platform/frontend/src/app/(platform)/copilot/components/usageHelpers.ts (1 conflict, ~9 lines)
    • autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/BriefingTabContent.tsx (9 conflicts, ~147 lines)
    • autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/StatsGrid.tsx (2 conflicts, ~9 lines)
    • autogpt_platform/frontend/src/app/(platform)/library/components/ContextualActionButton/ContextualActionButton.tsx (2 conflicts, ~12 lines)
    • autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/SitrepItem.tsx (2 conflicts, ~15 lines)
    • autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/useSitrepItems.ts (4 conflicts, ~97 lines)
    • autogpt_platform/frontend/src/app/(platform)/library/hooks/useAgentStatus.ts (2 conflicts, ~10 lines)
    • autogpt_platform/frontend/src/app/(platform)/library/hooks/useLibraryFleetSummary.ts (7 conflicts, ~57 lines)
    • autogpt_platform/frontend/src/app/(platform)/library/types.ts (1 conflict, ~4 lines)
    • autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/SubscriptionTierSection.tsx (10 conflicts, ~174 lines)
    • autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/__tests__/SubscriptionTierSection.test.tsx (21 conflicts, ~435 lines)
    • autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/useSubscriptionTierSection.ts (4 conflicts, ~60 lines)
    • autogpt_platform/frontend/src/app/api/openapi.json (2 conflicts, ~28 lines)
    • docs/integrations/block-integrations/llm.md (7 conflicts, ~35 lines)
    • docs/integrations/block-integrations/misc.md (1 conflict, ~5 lines)
  • fix(frontend): give every block form field an accessible name #12844 (djpjronline-netizen · updated 5d ago)

    • autogpt_platform/backend/backend/api/features/chat/routes.py (1 conflict, ~36 lines)
    • autogpt_platform/backend/backend/api/features/chat/routes_test.py (2 conflicts, ~734 lines)
    • autogpt_platform/backend/backend/api/features/subscription_routes_test.py (1 conflict, ~209 lines)
    • autogpt_platform/backend/backend/api/features/v1.py (6 conflicts, ~50 lines)
    • autogpt_platform/backend/backend/copilot/model_test.py (2 conflicts, ~183 lines)
    • autogpt_platform/backend/backend/data/credit.py (3 conflicts, ~200 lines)
    • autogpt_platform/backend/backend/data/credit_subscription_test.py (6 conflicts, ~1274 lines)
    • autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/helpers.test.ts (deleted here, modified there)
    • autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/helpers.ts (deleted here, modified there)
    • autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts (3 conflicts, ~45 lines)
    • autogpt_platform/frontend/src/app/(platform)/copilot/useLoadMoreMessages.ts (2 conflicts, ~42 lines)
    • autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/SubscriptionTierSection.tsx (6 conflicts, ~108 lines)
    • autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/useSubscriptionTierSection.ts (1 conflict, ~4 lines)
    • docs/integrations/block-integrations/llm.md (7 conflicts, ~35 lines)
    • docs/integrations/block-integrations/misc.md (1 conflict, ~5 lines)
  • feat(copilot): Auto-save binary block outputs using content-based detection #11984 (Otto-AGPT · updated 5d ago)

    • 📁 autogpt_platform/backend/backend/copilot/tools/
      • helpers.py (1 conflict, ~112 lines)
  • feat(platform): estimate CoPilot turn cost and require approval for high-cost requests #12877 (Rushi-Balapure · updated 2d ago)

    • 📁 autogpt_platform/backend/backend/
      • api/features/chat/routes.py (2 conflicts, ~32 lines)
      • util/feature_flag.py (1 conflict, ~9 lines)
  • fix(copilot): mandate gh auth status check before connect_integration #12852 (tianhaocui · updated 1d ago)

    • 📁 autogpt_platform/backend/backend/copilot/sdk/
      • service.py (1 conflict, ~20 lines)
  • Restructure platform documentation for GitBook and add changelogs #12669 (Torantulino · updated 13d ago)

🟢 Low Risk — File Overlap Only

These PRs touch the same files but different sections (click to expand)

Summary: 6 conflict(s), 0 medium risk, 10 low risk (out of 16 PRs with file overlap)


Auto-generated on push. Ignores: openapi.json, lock files.

@anvyle
anvyle requested review from majdyz and ntindle April 22, 2026 07:23
Comment thread autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py Outdated

@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

🧹 Nitpick comments (1)
autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py (1)

592-610: Split Drive-field detection coverage by schema cue.

_drive_sheets_block() always sets both format == "google-drive-picker" and auto_credentials.provider == "google", so the tests don’t prove the validator handles each documented detection path independently. Add one case for format-only and one for auto-credentials-only.

🧪 Suggested test shape
+    def test_format_only_drive_field_fails(self):
+        v = AgentValidator()
+        sheets = _drive_sheets_block()
+        spreadsheet_schema = sheets["inputSchema"]["properties"]["spreadsheet"]
+        spreadsheet_schema.pop("auto_credentials")
+        node = _make_node(
+            block_id=sheets["id"],
+            input_default={"spreadsheet": {"id": "1abc"}},
+        )
+
+        assert v.validate_google_drive_file_inputs(_make_agent(nodes=[node]), [sheets]) is False
+
+    def test_auto_credentials_only_drive_field_fails(self):
+        v = AgentValidator()
+        sheets = _drive_sheets_block()
+        spreadsheet_schema = sheets["inputSchema"]["properties"]["spreadsheet"]
+        spreadsheet_schema.pop("format")
+        node = _make_node(
+            block_id=sheets["id"],
+            input_default={"spreadsheet": {"id": "1abc"}},
+        )
+
+        assert v.validate_google_drive_file_inputs(_make_agent(nodes=[node]), [sheets]) is False
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py`
around lines 592 - 610, The test helper _drive_sheets_block currently sets both
format="google-drive-picker" and auto_credentials.provider="google", so update
tests in validator_test to cover the two independent detection paths: add one
block variant that only includes the input_schema property "spreadsheet" with
format "google-drive-picker" (remove auto_credentials) and another variant that
only includes "spreadsheet" with auto_credentials.provider="google" (remove
format), then add assertions that the validator recognizes Drive integration for
each variant; use the existing helper name _drive_sheets_block to create the
base and create two modified copies for format-only and auto-credentials-only
test cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md`:
- Around line 173-178: The fenced ASCII-art block containing
AgentGoogleDriveFileInputBlock → GoogleSheetsReadBlock / GoogleDocsReadBlock /
GoogleSheetsUpdateCellBlock / GoogleSlidesReadBlock should include a language
identifier so markdownlint treats it as code; update the fence that wraps the
block to use an explicit language (for example ```text) around the block showing
[AgentGoogleDriveFileInputBlock] and the related [GoogleSheetsReadBlock],
[GoogleDocsReadBlock], [GoogleSheetsUpdateCellBlock], [GoogleSlidesReadBlock]
entries.

In `@autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py`:
- Around line 778-816: The code currently treats any inbound link (linked_sinks)
as sufficient to skip Drive-file validation and only checks top-level
input_default keys, which lets non-picker links and nested defaults bypass
checks; update the link-collection and validation logic so linked_sinks records
the source block type and sink name (e.g., store tuples or map sink_id -> set of
(sink_name, source_block_type) using link.get("source_block_id") to lookup
block_lookup[...] .get("type")), then in the node loop only skip validation when
a linked sink is both sink_name == "result" and the source block type is
"AgentGoogleDriveFileInputBlock" (reference linked_sinks and block_lookup), and
when checking input_default treat nested keys as matches too (consider keys
equal to field_name or starting with f"{field_name}_" or descend into nested
dicts to find field_name) so values like "spreadsheet_#_id" or nested defaults
are validated.

---

Nitpick comments:
In
`@autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py`:
- Around line 592-610: The test helper _drive_sheets_block currently sets both
format="google-drive-picker" and auto_credentials.provider="google", so update
tests in validator_test to cover the two independent detection paths: add one
block variant that only includes the input_schema property "spreadsheet" with
format "google-drive-picker" (remove auto_credentials) and another variant that
only includes "spreadsheet" with auto_credentials.provider="google" (remove
format), then add assertions that the validator recognizes Drive integration for
each variant; use the existing helper name _drive_sheets_block to create the
base and create two modified copies for format-only and auto-credentials-only
test cases.
🪄 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

Run ID: ba937616-4823-4f88-982f-d8f66bd30dcc

📥 Commits

Reviewing files that changed from the base of the PR and between 33a608e and e3ec6fc.

📒 Files selected for processing (3)
  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: check API types
  • GitHub Check: Seer Code Review
  • GitHub Check: type-check (3.11)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: end-to-end tests
  • GitHub Check: Check PR Status
  • GitHub Check: Analyze (typescript)
  • GitHub Check: Analyze (python)
🧰 Additional context used
📓 Path-based instructions (4)
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/copilot/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
autogpt_platform/{backend,autogpt_libs}/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator_test.py
autogpt_platform/backend/**/*.md

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

Document agent responsibilities and interfaces in markdown files

Files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
🧠 Learnings (27)
📓 Common learnings
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/constants.py:9-12
Timestamp: 2026-03-10T08:39:22.025Z
Learning: In Significant-Gravitas/AutoGPT PR `#12356`, the `COPILOT_SYNTHETIC_ID_PREFIX = "copilot-"` check in `create_auto_approval_record` (human_review.py) is intentional and safe. The `graph_exec_id` passed to this function comes from server-side `PendingHumanReview` DB records (not from user input); the API only accepts `node_exec_id` from users. Synthetic `copilot-*` IDs are only ever created server-side in `run_block.py`. The prefix skip avoids a DB lookup for a `AgentGraphExecution` record that legitimately does not exist for CoPilot sessions, while `user_id` scoping is enforced at the auth layer and on the resulting auto-approval record.
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12879
File: autogpt_platform/backend/backend/copilot/baseline/service.py:0-0
Timestamp: 2026-04-22T05:57:34.861Z
Learning: In `autogpt_platform/backend/backend/copilot/baseline/service.py`, the approved pattern for `_run_task_subagent` (PR `#12879`, commit 187f0a5) uses a nested `try/except Exception` inside an outer `try/finally`. The outer `finally` block resets `_TASK_DEPTH_VAR` (via `_TASK_DEPTH_VAR.reset(token)`) AND calls `_absorb_inner_usage(parent_state, inner_state)` unconditionally, so both the depth ContextVar and usage roll-up are guaranteed on all exit paths including `CancelledError`/`KeyboardInterrupt`/`SystemExit`. The inner `except Exception` catches and converts failures into a `TaskResponse` error payload that is returned as `StreamToolOutputAvailable`. Do NOT flag missing ContextVar reset or usage roll-up on BaseException paths in this function.
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:12.102Z
Learning: Agents must validate inputs before processing
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/backend/backend/blocks/**/*.py : Write tests alongside block implementation when adding new blocks in backend

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py
📚 Learning: 2026-04-08T17:27:45.740Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-08T17:27:45.740Z
Learning: Applies to autogpt_platform/**/data/**/*.py : For changes touching `data/*.py`, validate user ID checks or explain why not needed

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-04-08T17:28:23.439Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/AGENTS.md:0-0
Timestamp: 2026-04-08T17:28:23.439Z
Learning: Applies to autogpt_platform/backend/backend/blocks/**/*.py : When creating new blocks, inherit from `Block` base class, define input/output schemas using `BlockSchema`, implement async `run` method, and generate unique block ID using `uuid.uuid4()`

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 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/copilot/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 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/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.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/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.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/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.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/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator_test.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-04-08T17:26:28.252Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:28.252Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/AGENTS.md : Document all agents in AGENTS.md with their name, description, input/output schemas, and usage examples

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-15T14:10:18.177Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/backend/copilot/graphiti/CLAUDE.md:0-0
Timestamp: 2026-04-15T14:10:18.177Z
Learning: Agent documentation should be maintained in AGENTS.md and kept synchronized with code changes

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-31T14:22:29.127Z
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:29.127Z
Learning: When reviewing code under autogpt_platform/backend/backend/copilot/tools/, the `AgentInfo.graph` field (in agent_search.py / models.py) uses `Graph | None` (the typed `backend.data.graph.Graph` Pydantic model), NOT `dict[str, Any]`. The enrichment function `_enrich_agents_with_graph` calls `graph_db().get_graph(graph_id, version=None, user_id=user_id)` directly rather than going through `get_agent_as_json()` / `graph_to_json()`. This was updated in PR `#12622` (commit 22d05bc).

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:26:18.189Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:18.189Z
Learning: Applies to autogpt_platform/backend/**/*.md : Document agent responsibilities and interfaces in markdown files

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:26:23.306Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:23.306Z
Learning: Applies to autogpt_platform/frontend/**/AGENTS.md : Document agent responsibilities and capabilities in AGENTS.md with clear descriptions of what each agent does

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:26:28.252Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:28.252Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/AGENTS.md : Include clear usage examples in AGENTS.md for each agent to facilitate integration and reduce onboarding time

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-08T23:28:21.675Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12334
File: docs/integrations/block-integrations/github/repo.md:11-40
Timestamp: 2026-03-08T23:28:21.675Z
Learning: In Significant-Gravitas/AutoGPT, new GitHub block documentation stubs in `docs/integrations/block-integrations/github/` are auto-generated by a docs script with placeholder text (`_Add technical explanation here._` / `_Add practical use case examples here._`) inside `<!-- MANUAL: how_it_works

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:26:28.252Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:28.252Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/AGENTS.md : Maintain AGENTS.md as the single source of truth for agent specifications and interfaces across the codebase

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-17T10:57:12.953Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12440
File: autogpt_platform/backend/backend/copilot/workflow_import/converter.py:0-0
Timestamp: 2026-03-17T10:57:12.953Z
Learning: In Significant-Gravitas/AutoGPT PR `#12440`, `autogpt_platform/backend/backend/copilot/workflow_import/converter.py` was fully rewritten (commit 732960e2d) to no longer make direct LLM/OpenAI API calls. The converter now builds a structured text prompt for AutoPilot/CoPilot instead. There is no `response.choices` access or any direct LLM client usage in this file. Do not flag `response.choices` access or LLM client initialization patterns as issues in this file.

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-04-15T14:10:18.177Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/backend/copilot/graphiti/CLAUDE.md:0-0
Timestamp: 2026-04-15T14:10:18.177Z
Learning: Applies to autogpt_platform/backend/backend/copilot/graphiti/**/*agent*.{ts,tsx,yaml,yml,json} : Agent configuration should be stored in separate YAML/JSON configuration files and not hardcoded

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/backend/backend/blocks/**/*.py : Inherit from 'Block' base class with input/output schemas when adding new blocks in backend

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-26T13:40:13.262Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12577
File: autogpt_platform/frontend/src/app/(platform)/admin/components/AdminUserSearch.tsx:0-0
Timestamp: 2026-03-26T13:40:13.262Z
Learning: In `autogpt_platform/frontend`, the non-legacy `Input` component (`TextField`) requires `label` and `id` props and has a fundamentally different API from the legacy `@/components/__legacy__/ui/input`. The entire admin section intentionally continues to use the legacy `Input` for simple form inputs (e.g., search boxes) where those props are unnecessary. Do not flag the use of `@/components/__legacy__/ui/input` in admin components as a blocking issue until a lightweight non-legacy Input alternative is available.

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:26:12.102Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:12.102Z
Learning: Agents must validate inputs before processing

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-03-16T16:30:20.657Z
Learnt from: Abhi1992002
Repo: Significant-Gravitas/AutoGPT PR: 12417
File: autogpt_platform/backend/backend/blocks/agent_mail/threads.py:80-102
Timestamp: 2026-03-16T16:30:20.657Z
Learning: In autogpt_platform/backend/backend/blocks/agent_mail/ (and other blocks under autogpt_platform/backend/backend/blocks/), the block executor framework (backend/executor/manager.py lines ~708-733) automatically catches all uncaught exceptions from a block's `run()` method and emits them on the `"error"` output. Explicit try/except blocks within `run()` are therefore not required for standard error propagation — they are only needed when partial output behaviour must be controlled (e.g., preventing some outputs from being yielded on failure, as in attachment blocks). This is the standard pattern across the codebase.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
🪛 markdownlint-cli2 (0.22.0)
autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md

[warning] 173-173: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (1)
autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md (1)

161-166: No changes needed—the documented allowed_views guidance is correct.

Both "DOCS" and "DOCUMENTS" are valid enum values in the AttachmentView type. The documentation correctly distinguishes their use: ["DOCUMENTS"] for specialized Docs blocks (as seen in actual implementations in docs.py), and ["DOCS", "SPREADSHEETS", "PRESENTATIONS"] for the generic Drive input block default. Generated graphs would accept either value without validation errors.

Comment thread autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md Outdated
Comment thread autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py Outdated
@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.91837% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.13%. Comparing base (cc1f692) to head (e488573).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #12880      +/-   ##
==========================================
+ Coverage   68.07%   68.13%   +0.06%     
==========================================
  Files        1919     1920       +1     
  Lines      149037   149235     +198     
  Branches    15541    15554      +13     
==========================================
+ Hits       101451   101683     +232     
+ Misses      44568    44530      -38     
- Partials     3018     3022       +4     
Flag Coverage Δ
platform-backend 77.77% <96.14%> (+0.03%) ⬆️
platform-frontend 25.13% <88.88%> (-0.01%) ⬇️
platform-frontend-e2e 30.95% <0.00%> (+0.73%) ⬆️

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

Components Coverage Δ
Platform Backend 77.77% <96.14%> (+0.03%) ⬆️
Platform Frontend 32.36% <88.88%> (+0.15%) ⬆️
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.

… feedback

- Only links whose source is an AgentGoogleDriveFileInputBlock (or subclass)
  suppress the anti-pattern check. A link from any other block does not
  carry `_credentials_id`, so it must not silence the validator. This uses
  the `node_lookup` parameter that was previously accepted but unused.
- Detect nested `_#_` hardcoded defaults (e.g. `spreadsheet_#_id`) as
  equivalent to a top-level hardcode — they bypass the picker credentials
  flow in the same way.
- Tag the fenced code block in agent_generation_guide.md with `text` to
  satisfy markdownlint.
- Add tests: format-only and auto-credentials-only detection paths, link
  from non-Drive source still flagged, nested `_#_` default still flagged.

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

🧹 Nitpick comments (1)
autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py (1)

831-844: Add block ID constant to helpers and import in validator.

The UUID d3b32f15-6fd7-40e3-be52-e083f51b19a2 at line 836 is hardcoded in the error message. Add AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID to helpers.py alongside the other block ID constants (following the existing AGENT_EXECUTOR_BLOCK_ID, AGENT_INPUT_BLOCK_ID, etc. pattern), export it in __all__, and import it in validator.py to replace the hardcoded UUID. This centralizes the reference, prevents drift if the ID ever changes, and enables other validators and fixer code to share the constant.

♻️ Proposed refactor
 from .helpers import (
     AGENT_EXECUTOR_BLOCK_ID,
+    AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID,
     AGENT_INPUT_BLOCK_ID,
     AGENT_OUTPUT_BLOCK_ID,
     ...
 )
...
-                    f"provided at run time by an AgentGoogleDriveFileInputBlock "
-                    f"(block_id 'd3b32f15-6fd7-40e3-be52-e083f51b19a2') so "
+                    f"provided at run time by an AgentGoogleDriveFileInputBlock "
+                    f"(block_id '{AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID}') so "
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py`
around lines 831 - 844, Replace the hardcoded UUID in the error string inside
Validator.add_error call with a shared constant: add
AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID = "d3b32f15-6fd7-40e3-be52-e083f51b19a2"
to helpers.py alongside the other AGENT_* block ID constants, export it via
__all__, then import that constant in validator.py and use
AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID in the f-string inside the validator
method (the add_error call shown) instead of the literal UUID so the validator
references the centralized symbol.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py`:
- Around line 831-844: Replace the hardcoded UUID in the error string inside
Validator.add_error call with a shared constant: add
AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID = "d3b32f15-6fd7-40e3-be52-e083f51b19a2"
to helpers.py alongside the other AGENT_* block ID constants, export it via
__all__, then import that constant in validator.py and use
AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID in the f-string inside the validator
method (the add_error call shown) instead of the literal UUID so the validator
references the centralized symbol.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d6e15aca-921b-49eb-8067-c35549b6bc8c

📥 Commits

Reviewing files that changed from the base of the PR and between e3ec6fc and fb49a76.

📒 Files selected for processing (3)
  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py
✅ Files skipped from review due to trivial changes (1)
  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator_test.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: check API types
  • GitHub Check: Seer Code Review
  • GitHub Check: Analyze (python)
  • GitHub Check: end-to-end tests
  • GitHub Check: type-check (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.12)
  • GitHub Check: Check PR Status
🧰 Additional context used
📓 Path-based instructions (2)
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/copilot/tools/agent_generator/validator.py
autogpt_platform/{backend,autogpt_libs}/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
🧠 Learnings (15)
📓 Common learnings
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/constants.py:9-12
Timestamp: 2026-03-10T08:39:22.025Z
Learning: In Significant-Gravitas/AutoGPT PR `#12356`, the `COPILOT_SYNTHETIC_ID_PREFIX = "copilot-"` check in `create_auto_approval_record` (human_review.py) is intentional and safe. The `graph_exec_id` passed to this function comes from server-side `PendingHumanReview` DB records (not from user input); the API only accepts `node_exec_id` from users. Synthetic `copilot-*` IDs are only ever created server-side in `run_block.py`. The prefix skip avoids a DB lookup for a `AgentGraphExecution` record that legitimately does not exist for CoPilot sessions, while `user_id` scoping is enforced at the auth layer and on the resulting auto-approval record.
📚 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/agent_generator/validator.py
📚 Learning: 2026-03-10T08:39:22.025Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/constants.py:9-12
Timestamp: 2026-03-10T08:39:22.025Z
Learning: In Significant-Gravitas/AutoGPT PR `#12356`, the `COPILOT_SYNTHETIC_ID_PREFIX = "copilot-"` check in `create_auto_approval_record` (human_review.py) is intentional and safe. The `graph_exec_id` passed to this function comes from server-side `PendingHumanReview` DB records (not from user input); the API only accepts `node_exec_id` from users. Synthetic `copilot-*` IDs are only ever created server-side in `run_block.py`. The prefix skip avoids a DB lookup for a `AgentGraphExecution` record that legitimately does not exist for CoPilot sessions, while `user_id` scoping is enforced at the auth layer and on the resulting auto-approval record.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-03-17T10:57:12.953Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12440
File: autogpt_platform/backend/backend/copilot/workflow_import/converter.py:0-0
Timestamp: 2026-03-17T10:57:12.953Z
Learning: In Significant-Gravitas/AutoGPT PR `#12440`, `autogpt_platform/backend/backend/copilot/workflow_import/converter.py` was fully rewritten (commit 732960e2d) to no longer make direct LLM/OpenAI API calls. The converter now builds a structured text prompt for AutoPilot/CoPilot instead. There is no `response.choices` access or any direct LLM client usage in this file. Do not flag `response.choices` access or LLM client initialization patterns as issues in this file.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-03-10T08:38:36.655Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/tools/run_block.py:349-370
Timestamp: 2026-03-10T08:38:36.655Z
Learning: In the AutoGPT CoPilot HITL (Human-In-The-Loop) flow (`autogpt_platform/backend/backend/copilot/tools/run_block.py`), the review card presented to users sets `editable: false`, meaning reviewers cannot modify the input payload. Therefore, credentials resolved before `is_block_exec_need_review()` remain valid and do not need to be recomputed after the review step — the original `input_data` is unchanged through the review lifecycle.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-04-08T17:26:12.102Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:12.102Z
Learning: Agents must validate inputs before processing

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-03-16T16:30:20.657Z
Learnt from: Abhi1992002
Repo: Significant-Gravitas/AutoGPT PR: 12417
File: autogpt_platform/backend/backend/blocks/agent_mail/threads.py:80-102
Timestamp: 2026-03-16T16:30:20.657Z
Learning: In autogpt_platform/backend/backend/blocks/agent_mail/ (and other blocks under autogpt_platform/backend/backend/blocks/), the block executor framework (backend/executor/manager.py lines ~708-733) automatically catches all uncaught exceptions from a block's `run()` method and emits them on the `"error"` output. Explicit try/except blocks within `run()` are therefore not required for standard error propagation — they are only needed when partial output behaviour must be controlled (e.g., preventing some outputs from being yielded on failure, as in attachment blocks). This is the standard pattern across the codebase.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 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/copilot/tools/agent_generator/validator.py
📚 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/tools/agent_generator/validator.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/tools/agent_generator/validator.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/agent_generator/validator.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/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator.py
🔇 Additional comments (3)
autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py (3)

658-733: LGTM on the IO-block refactor.

Switching from substring matching on block_id to a uiType-driven collection (with base IDs preserved as fallback for minimal test inputs) correctly accommodates specialized subclasses like AgentGoogleDriveFileInputBlock. The error messages now reference both the base block and the specialized variants, which is helpful guidance for the fixer LLM.


789-801: Drive-source link gating looks correct.

Restricting drive_linked_sinks to links whose source node is an AgentGoogleDriveFileInputBlock (or subclass) correctly enforces the _credentials_id requirement — a link from any other block can't provide the OAuth plumbing. The prior review concern about non-picker links silencing the check is addressed.


849-888: Optional/union-wrapped GoogleDriveFileField schemas are not currently at risk, but could be handled more defensively.

_is_google_drive_picker_field only inspects the top-level schema dict for format == "google-drive-picker" or auto_credentials.provider == "google". If a field were declared as Optional[GoogleDriveFileField], Pydantic v2 would emit {"anyOf": [{"format": "google-drive-picker", ...}, {"type": "null"}]}, placing both keys inside the union rather than at the top level.

However, this is not a current issue:

  • AgentGoogleDriveFileInputBlock.value is declared as Optional[GoogleDriveFileField], but its custom generate_schema() method manually places the picker markers (format and auto_credentials) at the top level, bypassing the anyOf wrapping.
  • All consumer blocks (e.g., GoogleSheetsReadBlock) use GoogleDriveFileField directly without Optional, so they emit markers at the top level.

Future-proofing would involve descending into anyOf variants (as check_nested_input does for dict validation at line 530), but this is a lower-priority improvement since no current code triggers the gap.

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md`:
- Around line 139-143: The docs show inconsistent allowed_views tokens: change
occurrences of "DOCS" in the examples/default list to the canonical "DOCUMENTS"
(or vice versa if project-wide canonical is "DOCS") so the guide uses one
consistent value; update the default array line that currently reads `["DOCS",
"SPREADSHEETS", "PRESENTATIONS"]` to `["DOCUMENTS", "SPREADSHEETS",
"PRESENTATIONS"]` to match the `["DOCUMENTS"]` example and avoid generating
invalid picker configs.
🪄 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

Run ID: 86086d5f-81a8-481c-8275-790c2c6fa0ed

📥 Commits

Reviewing files that changed from the base of the PR and between fb49a76 and 07d5dd3.

📒 Files selected for processing (1)
  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: check API types
  • GitHub Check: types
  • GitHub Check: test (3.12)
  • GitHub Check: type-check (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: lint
  • GitHub Check: test (3.13)
  • GitHub Check: type-check (3.11)
  • GitHub Check: type-check (3.12)
  • GitHub Check: lint
  • GitHub Check: end-to-end tests
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (typescript)
  • GitHub Check: Check PR Status
🧰 Additional context used
📓 Path-based instructions (1)
autogpt_platform/backend/**/*.md

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

Document agent responsibilities and interfaces in markdown files

Files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
🧠 Learnings (21)
📓 Common learnings
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/constants.py:9-12
Timestamp: 2026-03-10T08:39:22.025Z
Learning: In Significant-Gravitas/AutoGPT PR `#12356`, the `COPILOT_SYNTHETIC_ID_PREFIX = "copilot-"` check in `create_auto_approval_record` (human_review.py) is intentional and safe. The `graph_exec_id` passed to this function comes from server-side `PendingHumanReview` DB records (not from user input); the API only accepts `node_exec_id` from users. Synthetic `copilot-*` IDs are only ever created server-side in `run_block.py`. The prefix skip avoids a DB lookup for a `AgentGraphExecution` record that legitimately does not exist for CoPilot sessions, while `user_id` scoping is enforced at the auth layer and on the resulting auto-approval record.
📚 Learning: 2026-04-15T14:10:18.177Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/backend/copilot/graphiti/CLAUDE.md:0-0
Timestamp: 2026-04-15T14:10:18.177Z
Learning: Agent documentation should be maintained in AGENTS.md and kept synchronized with code changes

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:26:28.252Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:28.252Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/AGENTS.md : Document all agents in AGENTS.md with their name, description, input/output schemas, and usage examples

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:26:23.306Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:23.306Z
Learning: Applies to autogpt_platform/frontend/**/AGENTS.md : Document agent responsibilities and capabilities in AGENTS.md with clear descriptions of what each agent does

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:26:18.189Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:18.189Z
Learning: Applies to autogpt_platform/backend/**/*.md : Document agent responsibilities and interfaces in markdown files

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-08T23:28:21.675Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12334
File: docs/integrations/block-integrations/github/repo.md:11-40
Timestamp: 2026-03-08T23:28:21.675Z
Learning: In Significant-Gravitas/AutoGPT, new GitHub block documentation stubs in `docs/integrations/block-integrations/github/` are auto-generated by a docs script with placeholder text (`_Add technical explanation here._` / `_Add practical use case examples here._`) inside `<!-- MANUAL: how_it_works

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-17T10:57:12.953Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12440
File: autogpt_platform/backend/backend/copilot/workflow_import/converter.py:0-0
Timestamp: 2026-03-17T10:57:12.953Z
Learning: In Significant-Gravitas/AutoGPT PR `#12440`, `autogpt_platform/backend/backend/copilot/workflow_import/converter.py` was fully rewritten (commit 732960e2d) to no longer make direct LLM/OpenAI API calls. The converter now builds a structured text prompt for AutoPilot/CoPilot instead. There is no `response.choices` access or any direct LLM client usage in this file. Do not flag `response.choices` access or LLM client initialization patterns as issues in this file.

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-31T14:22:29.127Z
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:29.127Z
Learning: When reviewing code under autogpt_platform/backend/backend/copilot/tools/, the `AgentInfo.graph` field (in agent_search.py / models.py) uses `Graph | None` (the typed `backend.data.graph.Graph` Pydantic model), NOT `dict[str, Any]`. The enrichment function `_enrich_agents_with_graph` calls `graph_db().get_graph(graph_id, version=None, user_id=user_id)` directly rather than going through `get_agent_as_json()` / `graph_to_json()`. This was updated in PR `#12622` (commit 22d05bc).

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-15T14:10:18.177Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/backend/copilot/graphiti/CLAUDE.md:0-0
Timestamp: 2026-04-15T14:10:18.177Z
Learning: Applies to autogpt_platform/backend/backend/copilot/graphiti/**/*agent*.{ts,tsx} : All agent implementations should follow the standard agent interface pattern with methods for initialization, execution, and error handling

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:26:28.252Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:28.252Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/AGENTS.md : Maintain AGENTS.md as the single source of truth for agent specifications and interfaces across the codebase

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:26:28.252Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:28.252Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/AGENTS.md : Include clear usage examples in AGENTS.md for each agent to facilitate integration and reduce onboarding time

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-07T10:12:18.517Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12691
File: .claude/skills/orchestrate/SKILL.md:0-0
Timestamp: 2026-04-07T10:12:18.517Z
Learning: In Significant-Gravitas/AutoGPT's Claude skill markdown files under `.claude/skills/orchestrate/`, fenced code blocks in `SKILL.md`-style skill documents may intentionally omit a fenced code language (no `text`, `bash`, etc.). These blocks are used for Claude Code inline pseudocode/conceptual helpers rather than runnable scripts. During reviews, avoid treating MD040 (fenced-code-language) as an issue for these specific skill-format blocks, even if the language identifier is missing, since this omission is expected and has been accepted as a false positive for this skill format.

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-27T09:36:59.358Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12591
File: .claude/skills/setup-repo/SKILL.md:32-33
Timestamp: 2026-03-27T09:36:59.358Z
Learning: In the Significant-Gravitas/AutoGPT repository, bash code blocks inside `.claude/skills/*/SKILL.md` files are illustrative guidance patterns for AI agents to adapt, not directly executable scripts. Code correctness standards (e.g., regex safety, error handling) for these snippets should be evaluated against their role as intent-communicating documentation rather than production code.

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-10T08:39:22.025Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/constants.py:9-12
Timestamp: 2026-03-10T08:39:22.025Z
Learning: In Significant-Gravitas/AutoGPT PR `#12356`, the `COPILOT_SYNTHETIC_ID_PREFIX = "copilot-"` check in `create_auto_approval_record` (human_review.py) is intentional and safe. The `graph_exec_id` passed to this function comes from server-side `PendingHumanReview` DB records (not from user input); the API only accepts `node_exec_id` from users. Synthetic `copilot-*` IDs are only ever created server-side in `run_block.py`. The prefix skip avoids a DB lookup for a `AgentGraphExecution` record that legitimately does not exist for CoPilot sessions, while `user_id` scoping is enforced at the auth layer and on the resulting auto-approval record.

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-21T11:41:05.877Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 0
File: :0-0
Timestamp: 2026-04-21T11:41:05.877Z
Learning: In `autogpt_platform/backend/backend/copilot/baseline/service.py` (PR `#12870`, commits 080d42b9d and 3d7b38162), the `_close_reasoning_block_if_open(state)` helper centralises all four reasoning-block-close call sites (text branch, tool_calls branch, stream-end, exception path). The outer `finally` block of `_baseline_llm_caller` calls this helper plus stripper flush + `StreamTextEnd` to guarantee matched end events are emitted before `StreamFinishStep` on both normal and exception paths. Do NOT flag duplicated close logic or missing reasoning-end-on-exception as issues in this function.

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-07T18:08:03.548Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12701
File: .claude/skills/orchestrate/scripts/verify-complete.sh:120-121
Timestamp: 2026-04-07T18:08:03.548Z
Learning: In Significant-Gravitas/AutoGPT, verify-complete.sh (`.claude/skills/orchestrate/scripts/verify-complete.sh`) uses `commits[-1].committedDate` (not `updatedAt`) to identify stale CHANGES_REQUESTED reviews. This is intentional: `updatedAt` changes on any PR activity (bot comments, label changes, description edits), which would falsely classify a reviewer's CHANGES_REQUESTED as stale — a silent false negative. The `committedDate` edge case (commit created locally before a review but pushed after) only causes a false positive (unnecessary re-brief), which is the safer failure mode. Do not suggest switching to `updatedAt` for this comparison.

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-24T21:25:15.983Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12536
File: autogpt_platform/frontend/src/app/api/openapi.json:5770-5790
Timestamp: 2026-03-24T21:25:15.983Z
Learning: Repo: Significant-Gravitas/AutoGPT — PR `#12536`
File: autogpt_platform/frontend/src/app/api/openapi.json
Learning: The OpenAPI spec file is auto-generated; per established convention, endpoints generally declare only 200/201, 401, and 422 responses. Do not suggest adding explicit 403/404 response entries for single operations unless planning a repo-wide spec update. Prefer clarifying such behaviors in endpoint descriptions/docstrings instead of altering response maps.

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-04-08T17:28:23.439Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/AGENTS.md:0-0
Timestamp: 2026-04-08T17:28:23.439Z
Learning: Applies to autogpt_platform/backend/backend/blocks/**/*.py : When creating new blocks, inherit from `Block` base class, define input/output schemas using `BlockSchema`, implement async `run` method, and generate unique block ID using `uuid.uuid4()`

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/backend/backend/blocks/**/*.py : Inherit from 'Block' base class with input/output schemas when adding new blocks in backend

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 Learning: 2026-03-26T13:40:13.262Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12577
File: autogpt_platform/frontend/src/app/(platform)/admin/components/AdminUserSearch.tsx:0-0
Timestamp: 2026-03-26T13:40:13.262Z
Learning: In `autogpt_platform/frontend`, the non-legacy `Input` component (`TextField`) requires `label` and `id` props and has a fundamentally different API from the legacy `@/components/__legacy__/ui/input`. The entire admin section intentionally continues to use the legacy `Input` for simple form inputs (e.g., search boxes) where those props are unnecessary. Do not flag the use of `@/components/__legacy__/ui/input` in admin components as a blocking issue until a lightweight non-legacy Input alternative is available.

Applied to files:

  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📚 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/copilot/sdk/agent_generation_guide.md
🔇 Additional comments (1)
autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md (1)

114-191: Strong addition—this section clearly defines the Drive-file contract and wiring pattern.

The new required pattern, detection cues, and remediation guidance are concrete and should prevent the hardcoded-ID anti-pattern effectively.

As per coding guidelines, this update documents agent responsibilities and interfaces in markdown files.

Comment thread autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md Outdated
anvyle added 2 commits April 23, 2026 00:59
Use the same AttachmentView token (DOCS) that the runtime default uses in
io.py, so the guide and error message don't suggest DOCUMENTS while the
default list uses DOCS. Both are valid literals, but mixing them inside the
same paragraph makes the guidance inconsistent.

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

🧹 Nitpick comments (1)
autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py (1)

831-844: Avoid hard-coding the AgentGoogleDriveFileInputBlock UUID in the error string.

Line 836 embeds the literal 'd3b32f15-6fd7-40e3-be52-e083f51b19a2'. Any future ID change (or a test double) will silently drift the guidance while tests still pass. Prefer exporting a named constant from helpers (alongside AGENT_INPUT_BLOCK_ID/AGENT_OUTPUT_BLOCK_ID) and interpolating it.

♻️ Proposed fix
 from .helpers import (
     AGENT_EXECUTOR_BLOCK_ID,
+    AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID,
     AGENT_INPUT_BLOCK_ID,
     AGENT_OUTPUT_BLOCK_ID,
     MCP_TOOL_BLOCK_ID,
     TOOL_ORCHESTRATOR_BLOCK_ID,
-                    f"provided at run time by an AgentGoogleDriveFileInputBlock "
-                    f"(block_id 'd3b32f15-6fd7-40e3-be52-e083f51b19a2') so "
+                    f"provided at run time by an AgentGoogleDriveFileInputBlock "
+                    f"(block_id '{AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID}') so "
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py`
around lines 831 - 844, The error message in validator.py currently hardcodes
the AgentGoogleDriveFileInputBlock UUID; instead export a named constant (e.g.
AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID) from the helpers module alongside
AGENT_INPUT_BLOCK_ID / AGENT_OUTPUT_BLOCK_ID, import that constant into
autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py, and
replace the literal 'd3b32f15-6fd7-40e3-be52-e083f51b19a2' in the self.add_error
string with an f-string interpolation of the new constant so future ID changes
or test doubles will be reflected automatically.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py`:
- Around line 831-844: The error message in validator.py currently hardcodes the
AgentGoogleDriveFileInputBlock UUID; instead export a named constant (e.g.
AGENT_GOOGLE_DRIVE_FILE_INPUT_BLOCK_ID) from the helpers module alongside
AGENT_INPUT_BLOCK_ID / AGENT_OUTPUT_BLOCK_ID, import that constant into
autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py, and
replace the literal 'd3b32f15-6fd7-40e3-be52-e083f51b19a2' in the self.add_error
string with an f-string interpolation of the new constant so future ID changes
or test doubles will be reflected automatically.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 94484dab-0029-433b-af15-2565f26f5e75

📥 Commits

Reviewing files that changed from the base of the PR and between 07d5dd3 and 521c08e.

📒 Files selected for processing (2)
  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
✅ Files skipped from review due to trivial changes (1)
  • autogpt_platform/backend/backend/copilot/sdk/agent_generation_guide.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: check API types
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.11)
  • GitHub Check: type-check (3.13)
  • GitHub Check: type-check (3.12)
  • GitHub Check: test (3.13)
  • GitHub Check: end-to-end tests
  • GitHub Check: Check PR Status
🧰 Additional context used
📓 Path-based instructions (2)
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/copilot/tools/agent_generator/validator.py
autogpt_platform/{backend,autogpt_libs}/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
🧠 Learnings (25)
📓 Common learnings
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/constants.py:9-12
Timestamp: 2026-03-10T08:39:22.025Z
Learning: In Significant-Gravitas/AutoGPT PR `#12356`, the `COPILOT_SYNTHETIC_ID_PREFIX = "copilot-"` check in `create_auto_approval_record` (human_review.py) is intentional and safe. The `graph_exec_id` passed to this function comes from server-side `PendingHumanReview` DB records (not from user input); the API only accepts `node_exec_id` from users. Synthetic `copilot-*` IDs are only ever created server-side in `run_block.py`. The prefix skip avoids a DB lookup for a `AgentGraphExecution` record that legitimately does not exist for CoPilot sessions, while `user_id` scoping is enforced at the auth layer and on the resulting auto-approval record.
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12284
File: autogpt_platform/frontend/src/app/api/openapi.json:11897-11900
Timestamp: 2026-03-04T23:58:18.476Z
Learning: Repo: Significant-Gravitas/AutoGPT — PR `#12284`
Backend/frontend OpenAPI codegen convention: In backend/api/features/store/model.py, the StoreSubmission and StoreSubmissionAdminView models define submitted_at: datetime | None, changes_summary: str | None, and instructions: str | None with no default. This is intentional to produce “required but nullable” fields in OpenAPI (properties appear in required[] and use anyOf [type, null]). This matches Prisma’s submittedAt DateTime? and changesSummary String?. Do not flag this as a required/nullable mismatch.
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12440
File: autogpt_platform/backend/backend/copilot/workflow_import/converter.py:0-0
Timestamp: 2026-03-17T10:57:12.953Z
Learning: In Significant-Gravitas/AutoGPT PR `#12440`, `autogpt_platform/backend/backend/copilot/workflow_import/converter.py` was fully rewritten (commit 732960e2d) to no longer make direct LLM/OpenAI API calls. The converter now builds a structured text prompt for AutoPilot/CoPilot instead. There is no `response.choices` access or any direct LLM client usage in this file. Do not flag `response.choices` access or LLM client initialization patterns as issues in this file.
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12536
File: autogpt_platform/frontend/src/app/api/openapi.json:5770-5790
Timestamp: 2026-03-24T21:25:15.983Z
Learning: Repo: Significant-Gravitas/AutoGPT — PR `#12536`
File: autogpt_platform/frontend/src/app/api/openapi.json
Learning: The OpenAPI spec file is auto-generated; per established convention, endpoints generally declare only 200/201, 401, and 422 responses. Do not suggest adding explicit 403/404 response entries for single operations unless planning a repo-wide spec update. Prefer clarifying such behaviors in endpoint descriptions/docstrings instead of altering response maps.
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/tools/run_block.py:349-370
Timestamp: 2026-03-10T08:38:36.655Z
Learning: In the AutoGPT CoPilot HITL (Human-In-The-Loop) flow (`autogpt_platform/backend/backend/copilot/tools/run_block.py`), the review card presented to users sets `editable: false`, meaning reviewers cannot modify the input payload. Therefore, credentials resolved before `is_block_exec_need_review()` remain valid and do not need to be recomputed after the review step — the original `input_data` is unchanged through the review lifecycle.
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/api/openapi.json:9983-9995
Timestamp: 2026-02-27T15:59:00.370Z
Learning: Repo: Significant-Gravitas/AutoGPT PR: 12213 — OpenAPI/codegen
Learning: Ensuring a field is required in generated TS types needs two sides: (1) no default value on the Pydantic field, and (2) the OpenAPI model's "required" array must list it. For MCPToolInfo, making input_schema required in OpenAPI and removing Field(default_factory=dict) in the backend prevents optional typing drift.
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/api/openapi.json:9983-9995
Timestamp: 2026-02-27T15:59:00.370Z
Learning: Repo: Significant-Gravitas/AutoGPT PR: 12213 — Backend/frontend OpenAPI codegen
Learning: For MCP schema models, required OpenAPI fields must have no defaults in Pydantic. Specifically, MCPToolInfo.input_schema must be required (no Field(default_factory=dict)) so openapi.json emits it in "required", ensuring generated TS types treat input_schema as non-optional.
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/frontend/src/tests/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:28.252Z
Learning: Applies to autogpt_platform/frontend/src/tests/**/AGENTS.md : Document all agents in AGENTS.md with their name, description, input/output schemas, and usage examples
📚 Learning: 2026-04-08T17:27:45.740Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-08T17:27:45.740Z
Learning: Applies to autogpt_platform/**/data/**/*.py : For changes touching `data/*.py`, validate user ID checks or explain why not needed

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-04-08T17:26:12.102Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/CLAUDE.md:0-0
Timestamp: 2026-04-08T17:26:12.102Z
Learning: Agents must validate inputs before processing

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.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/agent_generator/validator.py
📚 Learning: 2026-03-10T08:39:22.025Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/constants.py:9-12
Timestamp: 2026-03-10T08:39:22.025Z
Learning: In Significant-Gravitas/AutoGPT PR `#12356`, the `COPILOT_SYNTHETIC_ID_PREFIX = "copilot-"` check in `create_auto_approval_record` (human_review.py) is intentional and safe. The `graph_exec_id` passed to this function comes from server-side `PendingHumanReview` DB records (not from user input); the API only accepts `node_exec_id` from users. Synthetic `copilot-*` IDs are only ever created server-side in `run_block.py`. The prefix skip avoids a DB lookup for a `AgentGraphExecution` record that legitimately does not exist for CoPilot sessions, while `user_id` scoping is enforced at the auth layer and on the resulting auto-approval record.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-03-17T10:57:12.953Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12440
File: autogpt_platform/backend/backend/copilot/workflow_import/converter.py:0-0
Timestamp: 2026-03-17T10:57:12.953Z
Learning: In Significant-Gravitas/AutoGPT PR `#12440`, `autogpt_platform/backend/backend/copilot/workflow_import/converter.py` was fully rewritten (commit 732960e2d) to no longer make direct LLM/OpenAI API calls. The converter now builds a structured text prompt for AutoPilot/CoPilot instead. There is no `response.choices` access or any direct LLM client usage in this file. Do not flag `response.choices` access or LLM client initialization patterns as issues in this file.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-03-10T08:38:36.655Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/tools/run_block.py:349-370
Timestamp: 2026-03-10T08:38:36.655Z
Learning: In the AutoGPT CoPilot HITL (Human-In-The-Loop) flow (`autogpt_platform/backend/backend/copilot/tools/run_block.py`), the review card presented to users sets `editable: false`, meaning reviewers cannot modify the input payload. Therefore, credentials resolved before `is_block_exec_need_review()` remain valid and do not need to be recomputed after the review step — the original `input_data` is unchanged through the review lifecycle.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-03-16T17:00:02.827Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12439
File: autogpt_platform/backend/backend/blocks/autogpt_copilot.py:0-0
Timestamp: 2026-03-16T17:00:02.827Z
Learning: In autogpt_platform/backend/backend/blocks/autogpt_copilot.py, the recursion guard uses two module-level ContextVars: `_copilot_recursion_depth` (tracks current nesting depth) and `_copilot_recursion_limit` (stores the chain-wide ceiling). On the first invocation, `_copilot_recursion_limit` is set to `max_recursion_depth`; nested calls use `min(inherited_limit, max_recursion_depth)`, so they can only lower the cap, never raise it. The entry/exit logic is extracted into module-level helper functions. This is the approved pattern for preventing runaway sub-agent recursion in AutogptCopilotBlock (PR `#12439`, commits 348e9f8e2 and 3b70f61b1).

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-03-18T14:03:32.534Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12473
File: autogpt_platform/backend/backend/copilot/tools/agent_browser_integration_test.py:86-195
Timestamp: 2026-03-18T14:03:32.534Z
Learning: In Significant-Gravitas/AutoGPT, the integration tests in `autogpt_platform/backend/backend/copilot/tools/agent_browser_integration_test.py` intentionally use real external URLs (example.com, httpbin.org). They are gated with `pytest.mark.skipif(shutil.which("agent-browser") is None, ...)`, so they are automatically skipped in standard CI where agent-browser is not installed. They are designed to be run explicitly inside the Docker environment to verify that system Chromium (AGENT_BROWSER_EXECUTABLE_PATH=/usr/bin/chromium) actually launches and can fetch pages end-to-end. Do not flag the use of real network calls in these tests as a flakiness concern.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-04-22T05:57:34.861Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12879
File: autogpt_platform/backend/backend/copilot/baseline/service.py:0-0
Timestamp: 2026-04-22T05:57:34.861Z
Learning: In `autogpt_platform/backend/backend/copilot/baseline/service.py`, the approved pattern for `_run_task_subagent` (PR `#12879`, commit 187f0a5) uses a nested `try/except Exception` inside an outer `try/finally`. The outer `finally` block resets `_TASK_DEPTH_VAR` (via `_TASK_DEPTH_VAR.reset(token)`) AND calls `_absorb_inner_usage(parent_state, inner_state)` unconditionally, so both the depth ContextVar and usage roll-up are guaranteed on all exit paths including `CancelledError`/`KeyboardInterrupt`/`SystemExit`. The inner `except Exception` catches and converts failures into a `TaskResponse` error payload that is returned as `StreamToolOutputAvailable`. Do NOT flag missing ContextVar reset or usage roll-up on BaseException paths in this function.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-04-07T18:08:03.548Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12701
File: .claude/skills/orchestrate/scripts/verify-complete.sh:120-121
Timestamp: 2026-04-07T18:08:03.548Z
Learning: In Significant-Gravitas/AutoGPT, verify-complete.sh (`.claude/skills/orchestrate/scripts/verify-complete.sh`) uses `commits[-1].committedDate` (not `updatedAt`) to identify stale CHANGES_REQUESTED reviews. This is intentional: `updatedAt` changes on any PR activity (bot comments, label changes, description edits), which would falsely classify a reviewer's CHANGES_REQUESTED as stale — a silent false negative. The `committedDate` edge case (commit created locally before a review but pushed after) only causes a false positive (unnecessary re-brief), which is the safer failure mode. Do not suggest switching to `updatedAt` for this comparison.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-03-04T23:58:18.476Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12284
File: autogpt_platform/frontend/src/app/api/openapi.json:11897-11900
Timestamp: 2026-03-04T23:58:18.476Z
Learning: Repo: Significant-Gravitas/AutoGPT — PR `#12284`
Backend/frontend OpenAPI codegen convention: In backend/api/features/store/model.py, the StoreSubmission and StoreSubmissionAdminView models define submitted_at: datetime | None, changes_summary: str | None, and instructions: str | None with no default. This is intentional to produce “required but nullable” fields in OpenAPI (properties appear in required[] and use anyOf [type, null]). This matches Prisma’s submittedAt DateTime? and changesSummary String?. Do not flag this as a required/nullable mismatch.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-03-10T08:38:33.249Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12356
File: autogpt_platform/backend/backend/copilot/tools/run_block.py:297-300
Timestamp: 2026-03-10T08:38:33.249Z
Learning: In autogpt_platform/backend/backend/copilot/tools/run_block.py, the auto-approval key for sensitive block HITL review uses graph_exec_id (copilot-session-{session_id}) + node_id (copilot-node-{block_id}). This is intentional: approving a block type within a CoPilot session auto-approves all future invocations of that same block type within the same session, mirroring how auto-approve works in normal graph execution. The user explicitly opts into this session-scoped behavior via an auto-approve toggle. Without the toggle (default), each individual invocation requires its own approval.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 Learning: 2026-02-27T15:59:00.370Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/api/openapi.json:9983-9995
Timestamp: 2026-02-27T15:59:00.370Z
Learning: Repo: Significant-Gravitas/AutoGPT PR: 12213 — OpenAPI/codegen
Learning: Ensuring a field is required in generated TS types needs two sides: (1) no default value on the Pydantic field, and (2) the OpenAPI model's "required" array must list it. For MCPToolInfo, making input_schema required in OpenAPI and removing Field(default_factory=dict) in the backend prevents optional typing drift.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.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/tools/agent_generator/validator.py
📚 Learning: 2026-03-16T16:30:20.657Z
Learnt from: Abhi1992002
Repo: Significant-Gravitas/AutoGPT PR: 12417
File: autogpt_platform/backend/backend/blocks/agent_mail/threads.py:80-102
Timestamp: 2026-03-16T16:30:20.657Z
Learning: In autogpt_platform/backend/backend/blocks/agent_mail/ (and other blocks under autogpt_platform/backend/backend/blocks/), the block executor framework (backend/executor/manager.py lines ~708-733) automatically catches all uncaught exceptions from a block's `run()` method and emits them on the `"error"` output. Explicit try/except blocks within `run()` are therefore not required for standard error propagation — they are only needed when partial output behaviour must be controlled (e.g., preventing some outputs from being yielded on failure, as in attachment blocks). This is the standard pattern across the codebase.

Applied to files:

  • autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py
📚 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/copilot/tools/agent_generator/validator.py
📚 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/tools/agent_generator/validator.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/agent_generator/validator.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/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator.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/copilot/tools/agent_generator/validator.py
🔇 Additional comments (1)
autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py (1)

658-733: No changes required — uiType key is consistent across serialization and validation.

The original concern about a mismatch between uiType (read by the validator) and ui_type (used in tests) is unfounded. The test helper function has a parameter named ui_type (Python convention), but it correctly writes block["uiType"] to the dict (line 75 of validator_test.py). Production serialization in _base.py (line 611, 629) also produces "uiType". All code paths use the camelCase key consistently; the snake_case parameter name in the test is incidental and does not affect the dict serialization.

Comment thread autogpt_platform/backend/backend/copilot/tools/agent_generator/validator.py Outdated
ntindle
ntindle previously approved these changes Apr 23, 2026
The agent-generation-guide collapse expanded the AgentGoogleDriveFileInput
block description. Regenerate the auto-maintained block docs so
check-docs-sync passes.
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Apr 24, 2026
Comment thread autogpt_platform/backend/backend/executor/auto_credentials.py Outdated
Comment thread autogpt_platform/backend/backend/blocks/google/_drive.py Outdated
Comment thread autogpt_platform/backend/backend/copilot/tools/helpers.py
Comment thread autogpt_platform/backend/backend/executor/auto_credentials.py
majdyz added 2 commits April 24, 2026 09:50
…sError

field_name, provider, and picker_config were attached to the exception
but never read by any caller (CoPilot's execute_block only uses str(e)
and rebuilds the picker UI from the full input schema via
get_inputs_from_schema). picker_config in particular was never even
passed at construction time. Remove the dead surface area.
@majdyz

majdyz commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

/pr-test --fix report — GO

E2E pass on fix/copilot-drive-file-validator (with dev merged, 1028570eb).

Scenarios

# Scenario Result
1 Unit suites — validator_test (48), helpers_test (36), manager_auto_credentials_test (15) PASS 99/99
2 Frontend — SetupRequirementsCard helpers + component tests PASS 82/82
3 Validator subclass acceptance (direct call) — agent with only AgentGoogleDriveFileInputBlock + AgentOutputBlock passes validate_io_blocks when blocks registry is passed; base-ID fallback preserved for test-call shape PASS
4 Validator generality — AgentDropdownInputBlock accepted as sole input via uiType=="Input" PASS
5 CoPilot run_blockSetupRequirementsResponseexecute_block returns the setup card when the picker field is null or empty-string; returns ErrorResponse when the field is fully omitted (see observation below) PASS
6 UI setup card with Drive picker — live CoPilot chat called run_block, backend returned setup card, frontend rendered custom/google_drive_picker_field (verified via React fiber: uiSchema: {spreadsheet: {"ui:field": "custom/google_drive_picker_field"}}). "Add account" shows for unauthed user — correct pre-picker flow PASS
7 Agent generation end-to-end — asked CoPilot to build agent with sole AgentGoogleDriveFileInputBlock + Google Sheets consumer; validate_agent_graph returned success, create_agent created graph cdc4a27d-59ea-4e57-add4-fc37ab11c2db with exactly 3 nodes (input block, Sheets consumer, output block) — no throwaway base AgentInputBlock PASS

Fixes committed

None.

Non-blocking observations (follow-ups)

  • Setup card shows (text) next to the Spreadsheet label even though the field renders as the Drive picker. Cosmetic — derived from the TYPE_MAP fallback in buildExpectedInputsSchema when input.type === "object".
  • Fully omitting a picker field (rather than passing null) currently reaches the block and fails at the credential check. The new prompt section says "omit"; observed LLM behaviour is to pass null, which triggers the intended setup card. Could be tightened by treating absent-but-required picker fields as missing.

Verdict

GO — safe to merge / deploy. Headline features verified end-to-end:

  1. Validator accepts AgentInputBlock subclasses (live agent-gen created a subclass-only graph).
  2. run_block surfaces the inline Drive picker via the existing SetupRequirementsResponse path.

majdyz added 2 commits April 24, 2026 10:14
…Card helpers

Adds 6 cases exercising coerceExpectedInputs + buildExpectedInputsSchema against the generic schema-key passthrough (format / google_drive_picker_config / auto_credentials), plus the reserved-key isolation check. Closes the codecov/patch gap on the frontend diff.
…inputs + elevate run_block prompt

Observed on dev: when asked to read a private Google Sheet, CoPilot
answered "I can't access private sheets, share publicly or use the
builder" instead of calling run_block and letting the picker render.
Self-diagnosis confirmed the LLM knew the rule ("omit the spreadsheet
field, the picker will appear") but didn't apply it — the rule was
buried in a tool-notes sub-section and the fallback path (omit required
field) returned a schema preview, not the picker card.

Fixes:

- run_block: when missing required fields include picker-backed fields
  (format=google-drive-picker or auto_credentials present), return
  SetupRequirementsResponse directly so the frontend renders the picker
  inline. Previous behaviour returned BlockDetailsResponse (schema
  preview) which made the LLM's next guess "ask the user for the URL."

- prompting: elevate "Picker-backed inputs via run_block" to a
  top-level tool-behavior note. Add a concrete worked example (exact
  JSON), an explicit ❌ list ("don't ask for URL", "don't hardcode ID",
  "don't refuse"), and make clear the picker is the ONLY source of the
  attached credentials.

- auto_credentials: sharpen MissingAutoCredentialsError message to
  mention the inline picker so the LLM understands the retry path
  instead of asking the user for more data.

Test: new test_missing_picker_field_returns_setup_requirements in
run_block_test.py covering the picker-short-circuit branch.
majdyz added 3 commits April 24, 2026 11:02
Introduced by #12883 — module-level `import secrets` sat after class/function definitions, tripping ruff E402 on our branch post-merge. One-line hoist unblocks lint.
…picker prompt

Refactor: instead of a dedicated validate_only branch that rebuilt the BlockDetailsResponse, piggyback on the existing schema-preview return. Guard the picker short-circuit with `not validate_only` so introspection never renders a setup card. Detail message is now dynamic (ready-to-run vs missing-inputs list). Prompt section deduped + generalized — dropped the Drive/Sheets/Docs-specific wording; now speaks about picker-backed fields and their detection via schema hints without naming any provider. validate_only pre-flight documented as the safe probe for no-required-field blocks.
@majdyz majdyz changed the title fix(backend/copilot): validate Google Drive file anti-pattern + accept AgentInputBlock subclasses feat(backend/copilot): inline picker-backed inputs via run_block + accept AgentInputBlock subclasses Apr 24, 2026
Comment thread autogpt_platform/backend/backend/copilot/tools/helpers.py Outdated
majdyz added 3 commits April 24, 2026 12:22
…red lock leak

- Move picker-backed required-field detection from run_block.py into `prepare_block_for_execution` — extends the existing `if missing_credentials and not dry_run` branch's SetupRequirementsResponse instead of constructing a parallel copy. Both OAuth-missing and picker-missing now flow through the same setup-card builder.

- Wrap execute_block's post-auto-cred body in a try/finally so locks release on ALL exit paths (coerce raise, credit-check raise, insufficient-balance early return, timeout). Previously the inner wait_for try/finally was the only release path, stranding locks in Redis until TTL if anything raised before it. Addresses Sentry review r3135420231.

- Inline the `full_description` local in GoogleDriveFileField.
Two new regression tests for Sentry r3135420231: confirm auto_locks release when (a) coerce_inputs_to_schema raises between acquire and the inner wait_for try, (b) insufficient-credits early-return fires before execution. Both paths bypassed the inner finally pre-e5d069cfd; now covered by the outer try/finally that wraps the post-acquire body.
Comment thread autogpt_platform/backend/backend/copilot/tools/helpers.py Outdated
…are_block_for_execution

Sentry r3135709745: calling run_block with validate_only=True on a block with missing picker-backed required fields was returning SetupRequirementsResponse (rendering the picker) because the early-return branch in prepare_block_for_execution only gated on dry_run, not validate_only. The flag flowed through run_block but never reached the check.

Fix: add validate_only param to prepare_block_for_execution and include it in the guard; run_block passes it through. New test test_validate_only_bypasses_picker_setup_card covers the exact condition.
@majdyz
majdyz merged commit 3aa72b4 into dev Apr 24, 2026
45 checks passed
@github-project-automation github-project-automation Bot moved this from 👍🏼 Mergeable to ✅ Done in AutoGPT development kanban Apr 24, 2026
@github-project-automation github-project-automation Bot moved this to Done in Frontend Apr 24, 2026
@majdyz
majdyz deleted the fix/copilot-drive-file-validator branch April 24, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation platform/backend AutoGPT Platform - Back end platform/blocks platform/frontend AutoGPT Platform - Front end size/xl

Projects

Status: ✅ Done
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants