Skip to content

feat(backend,frontend): add explicit safe mode toggles for HITL and sensitive actions - #11756

Merged
majdyz merged 19 commits into
devfrom
feat/ai-generated-mode
Jan 21, 2026
Merged

feat(backend,frontend): add explicit safe mode toggles for HITL and sensitive actions#11756
majdyz merged 19 commits into
devfrom
feat/ai-generated-mode

Conversation

@majdyz

@majdyz majdyz commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR introduces two explicit safe mode toggles for controlling agent execution behavior, providing clearer and more granular control over when agents should pause for human review.

Key Changes

New Safe Mode Settings:

  • human_in_the_loop_safe_mode (bool, default true) - Controls whether human-in-the-loop (HITL) blocks pause for review
  • sensitive_action_safe_mode (bool, default false) - Controls whether sensitive action blocks pause for review

New Computed Properties on LibraryAgent:

  • has_human_in_the_loop - Indicates if agent contains HITL blocks
  • has_sensitive_action - Indicates if agent contains sensitive action blocks

Block Changes:

  • Renamed requires_human_review to is_sensitive_action on blocks for clarity
  • Blocks marked as is_sensitive_action=True pause only when sensitive_action_safe_mode=True
  • HITL blocks pause when human_in_the_loop_safe_mode=True

Frontend Changes:

  • Two separate toggles in Agent Settings based on block types present
  • Toggle visibility based on has_human_in_the_loop and has_sensitive_action computed properties
  • Settings cog hidden if neither toggle applies
  • Proper state management for both toggles with defaults

AI-Generated Agent Behavior:

  • AI-generated agents set sensitive_action_safe_mode=True by default
  • This ensures sensitive actions are reviewed for AI-generated content

Changes

Backend:

  • backend/data/graph.py - Updated GraphSettings with two boolean toggles (non-optional with defaults), added has_sensitive_action computed property
  • backend/data/block.py - Renamed requires_human_review to is_sensitive_action, updated review logic
  • backend/data/execution.py - Updated ExecutionContext with both safe mode fields
  • backend/api/features/library/model.py - Added has_human_in_the_loop and has_sensitive_action to LibraryAgent
  • backend/api/features/library/db.py - Updated to use sensitive_action_safe_mode parameter
  • backend/executor/utils.py - Simplified execution context creation

Frontend:

  • useAgentSafeMode.ts - Rewritten to support two independent toggles
  • AgentSettingsModal.tsx - Shows two separate toggles
  • SelectedSettingsView.tsx - Shows two separate toggles
  • Regenerated API types with new schema

Test Plan

  • All backend tests pass (Python 3.11, 3.12, 3.13)
  • All frontend tests pass
  • Backend format and lint pass
  • Frontend format and lint pass
  • Pre-commit hooks pass

…_the_loop_safe_mode duplication

- Add is_ai_generated_graph field to GraphSettings with default false
- Add GraphSettings.from_graph() class method for initialization
- Add is_ai_generated_graph to ExecutionContext
- Update block review logic: required_human_review blocks only pause for review if safe_mode=True AND is_ai_generated_graph=True
- HITL blocks continue to respect only safe_mode (unchanged)
- Expose is_ai_generated in CreateGraph API model and create_new_graph endpoint

Cleanup:
- Remove redundant update_library_agent_settings wrapper function (25 lines)
- Inline human_in_the_loop_safe_mode initialization logic using GraphSettings.from_graph()
- Remove unnecessary branching and comments
- Total: 68 lines removed, 34 lines added

Tests: All 33 tests passing (26 API + 7 executor)
@majdyz
majdyz requested a review from a team as a code owner January 12, 2026 21:13
@majdyz
majdyz requested review from Pwuts and Swiftyos and removed request for a team January 12, 2026 21:13
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Jan 12, 2026
@github-actions github-actions Bot added platform/backend AutoGPT Platform - Back end size/l labels Jan 12, 2026
@coderabbitai

coderabbitai Bot commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@majdyz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 60babcd and b7d6b1a.

📒 Files selected for processing (5)
  • autogpt_platform/backend/backend/data/execution.py
  • autogpt_platform/backend/backend/executor/scheduler.py
  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
  • autogpt_platform/frontend/src/app/api/openapi.json

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Split a single safe_mode into two flags—human_in_the_loop_safe_mode and sensitive_action_safe_mode—and propagate them through graph settings, data models, execution context, HITL/sensitive-action gating, library-agent creation/updates, frontend toggles/hooks, OpenAPI schemas, snapshots, and tests.

Changes

Cohort / File(s) Summary
Core data models
autogpt_platform/backend/backend/data/execution.py, autogpt_platform/backend/backend/data/block.py, autogpt_platform/backend/backend/data/graph.py
Replace safe_mode with human_in_the_loop_safe_mode + sensitive_action_safe_mode; rename requires_human_reviewis_sensitive_action; add GraphSettings.from_graph(...) and Graph.has_sensitive_action; simplify HITL detection.
Library agent backend
autogpt_platform/backend/backend/api/features/library/db.py, autogpt_platform/backend/backend/api/features/library/model.py, autogpt_platform/backend/backend/api/features/library/routes_test.py
Remove _initialize_graph_settings() and update_library_agent_settings(); create_library_agent() now accepts hitl_safe_mode and sensitive_action_safe_mode and uses GraphSettings.from_graph(...).model_dump(); LibraryAgent exposes has_human_in_the_loop and has_sensitive_action; tests updated.
API endpoints & agent generation
autogpt_platform/backend/backend/api/features/v1.py, autogpt_platform/backend/backend/api/features/chat/tools/agent_generator/core.py
Update calls to use GraphSettings.from_graph(...) and consolidated update_library_agent(...) path; agent generator passes sensitive_action_safe_mode when saving agents.
Execution & HITL review flow
autogpt_platform/backend/backend/executor/utils.py, autogpt_platform/backend/backend/blocks/human_in_the_loop.py, autogpt_platform/backend/backend/blocks/helpers/review.py
ExecutionContext carries both safe-mode flags; HITL gating uses human_in_the_loop_safe_mode; sensitive-action gating uses sensitive_action_safe_mode; propagate flags at execution creation.
Frontend hook & components
autogpt_platform/frontend/src/hooks/useAgentSafeMode.ts, various components (SelectedSettingsView, AgentSettingsModal, FloatingSafeModeToogle, SafeModeToggle, etc.)
Replace single safe-mode toggle with two toggles (HITL & sensitive-action); add separate state, handlers, visibility flags, expanded hook return values, and UI updates across relevant components.
Public API / OpenAPI & snapshots
autogpt_platform/frontend/src/app/api/openapi.json, autogpt_platform/backend/snapshots/*
Add has_sensitive_action to schemas and snapshots; add sensitive_action_safe_mode to GraphSettings; make human_in_the_loop_safe_mode a concrete boolean with default; update related response models.
Tests & minor updates
autogpt_platform/backend/backend/blocks/test/*, autogpt_platform/backend/backend/executor/utils_test.py
Update tests to use human_in_the_loop_safe_mode, add sensitive_action_safe_mode in mocks, and update library-agent test fixtures to include new flags.

Sequence Diagram(s)

sequenceDiagram
  actor Client
  participant Frontend
  participant API
  participant DB
  participant Executor
  participant Reviewer

  Client->>Frontend: toggle settings / start run
  Frontend->>API: create_new_graph / update_library_agent (includes GraphSettings.from_graph with human_in_the_loop_safe_mode & sensitive_action_safe_mode)
  API->>DB: store graph & library agent (settings saved)
  Client->>API: request execution
  API->>Executor: add_graph_execution(graph_id, settings)
  Executor->>Executor: construct ExecutionContext(human_in_the_loop_safe_mode, sensitive_action_safe_mode)
  Executor->>Executor: run block
  alt block.is_sensitive_action and execution_context.sensitive_action_safe_mode == true
    Executor->>Reviewer: trigger sensitive-action review
  else block.block_type == HUMAN_IN_THE_LOOP and execution_context.human_in_the_loop_safe_mode == true
    Executor->>Reviewer: trigger HITL review
  else
    Executor->>Executor: auto-approve and continue
  end
  Reviewer->>Executor: decision (approve/reject)
  Executor->>API: record run result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

Possible security concern, Review effort 4/5

Suggested reviewers

  • ntindle
  • kcze
  • Swiftyos
  • Bentlybro

Poem

🐰 One flag split into a pair,
HITL hops and sensitive care,
Graphs now show what they must share,
Two safe modes tend every snare—
carrots for careful code, we declare.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: introducing explicit safe mode toggles for HITL and sensitive actions, which is the core objective of the PR.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, covering key changes, affected files, test plan, and implementation details.

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


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.

@qodo-code-review

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Settings Reset

The new logic recalculates settings via GraphSettings.from_graph(agent_graph) and then conditionally writes them back. Since from_graph() always sets human_in_the_loop_safe_mode to True when HITL exists (and None otherwise), this can unintentionally overwrite a user’s previously chosen setting (e.g., user explicitly disabled safe mode) whenever the graph active version changes.

async def _update_library_agent_version_and_settings(
    user_id: str, agent_graph: graph_db.GraphModel
) -> library_model.LibraryAgent:
    library = await library_db.update_agent_version_in_library(
        user_id, agent_graph.id, agent_graph.version
    )
    updated_settings = GraphSettings.from_graph(agent_graph)
    if updated_settings != library.settings:
        library = await library_db.update_library_agent(
            library_agent_id=library.id,
            user_id=user_id,
            settings=updated_settings,
        )
    return library
Type Mismatch

The comparison updated_settings != library.settings assumes library.settings is a GraphSettings instance. In several call sites settings are stored via SafeJson(... .model_dump()), which may yield a dict/JSON type when read back. If library.settings is not a GraphSettings, this comparison may be unreliable and could cause either unnecessary writes or skipped updates.

updated_settings = GraphSettings.from_graph(agent_graph)
if updated_settings != library.settings:
    library = await library_db.update_library_agent(
        library_agent_id=library.id,
        user_id=user_id,
        settings=updated_settings,
    )
Behavior Change

Review gating for required_human_review now depends on execution_context.is_ai_generated_graph in addition to safe_mode. This is a product-intended change, but it’s worth validating that all execution entry points correctly populate is_ai_generated_graph (including sub-graphs / nested executions) so review isn’t silently bypassed when it should apply.

if not (
    self.requires_human_review
    and execution_context.safe_mode
    and execution_context.is_ai_generated_graph
):
    return False, input_data

Comment thread autogpt_platform/backend/backend/api/features/v1.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: 1

🤖 Fix all issues with AI agents
In @autogpt_platform/backend/backend/api/features/v1.py:
- Around line 895-901: GraphSettings.from_graph(agent_graph) creates
updated_settings with is_ai_generated defaulting to False and overwrites
library.settings when you call library_db.update_library_agent; preserve the
existing flag by copying library.settings.is_ai_generated_graph into
updated_settings (e.g., set updated_settings.is_ai_generated_graph =
library.settings.is_ai_generated_graph) before comparing and calling
library_db.update_library_agent so the existing is_ai_generated_graph value
isn’t lost.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between db8b43b and 7133580.

📒 Files selected for processing (7)
  • autogpt_platform/backend/backend/api/features/library/db.py
  • autogpt_platform/backend/backend/api/features/v1.py
  • autogpt_platform/backend/backend/api/model.py
  • autogpt_platform/backend/backend/data/block.py
  • autogpt_platform/backend/backend/data/execution.py
  • autogpt_platform/backend/backend/data/graph.py
  • autogpt_platform/backend/backend/executor/utils.py
🧰 Additional context used
📓 Path-based instructions (5)
autogpt_platform/backend/**/*.py

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

autogpt_platform/backend/**/*.py: Always run backend setup commands in order: poetry install, poetry run prisma migrate dev, poetry run prisma generate before backend development
Always run poetry run format (Black + isort) before poetry run lint (ruff) for backend code
Use Python 3.10-3.13 with Python 3.11 required for development (managed by Poetry via pyproject.toml)

Run linting and formatting: use poetry run format (Black + isort) to auto-fix, and poetry run lint (ruff) to check remaining errors

Files:

  • autogpt_platform/backend/backend/api/model.py
  • autogpt_platform/backend/backend/data/block.py
  • autogpt_platform/backend/backend/executor/utils.py
  • autogpt_platform/backend/backend/data/execution.py
  • autogpt_platform/backend/backend/data/graph.py
  • autogpt_platform/backend/backend/api/features/library/db.py
  • autogpt_platform/backend/backend/api/features/v1.py
autogpt_platform/{backend,autogpt_libs}/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/api/model.py
  • autogpt_platform/backend/backend/data/block.py
  • autogpt_platform/backend/backend/executor/utils.py
  • autogpt_platform/backend/backend/data/execution.py
  • autogpt_platform/backend/backend/data/graph.py
  • autogpt_platform/backend/backend/api/features/library/db.py
  • autogpt_platform/backend/backend/api/features/v1.py
autogpt_platform/backend/**

📄 CodeRabbit inference engine (autogpt_platform/CLAUDE.md)

autogpt_platform/backend/**: Install dependencies for backend using poetry install
Run database migrations using poetry run prisma migrate dev

Files:

  • autogpt_platform/backend/backend/api/model.py
  • autogpt_platform/backend/backend/data/block.py
  • autogpt_platform/backend/backend/executor/utils.py
  • autogpt_platform/backend/backend/data/execution.py
  • autogpt_platform/backend/backend/data/graph.py
  • autogpt_platform/backend/backend/api/features/library/db.py
  • autogpt_platform/backend/backend/api/features/v1.py
autogpt_platform/backend/backend/data/**/*.py

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

All data access in backend data/*.py files must include user ID validation checks

Files:

  • autogpt_platform/backend/backend/data/block.py
  • autogpt_platform/backend/backend/data/execution.py
  • autogpt_platform/backend/backend/data/graph.py
autogpt_platform/**/data/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

For changes touching data/*.py, validate user ID checks or explain why not needed

Files:

  • autogpt_platform/backend/backend/data/block.py
  • autogpt_platform/backend/backend/data/execution.py
  • autogpt_platform/backend/backend/data/graph.py
🧬 Code graph analysis (2)
autogpt_platform/backend/backend/api/features/library/db.py (2)
autogpt_platform/backend/backend/data/graph.py (3)
  • GraphSettings (64-75)
  • from_graph (69-75)
  • from_graph (825-826)
autogpt_platform/backend/backend/blocks/apollo/models.py (1)
  • model_dump (11-20)
autogpt_platform/backend/backend/api/features/v1.py (2)
autogpt_platform/backend/backend/api/features/library/db.py (2)
  • create_library_agent (404-469)
  • update_library_agent (534-613)
autogpt_platform/backend/backend/data/graph.py (3)
  • GraphSettings (64-75)
  • from_graph (69-75)
  • from_graph (825-826)
⏰ 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). (7)
  • GitHub Check: types
  • GitHub Check: Seer Code Review
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.13)
  • GitHub Check: Analyze (python)
  • GitHub Check: Check PR Status
🔇 Additional comments (10)
autogpt_platform/backend/backend/data/execution.py (1)

84-86: LGTM!

The new is_ai_generated_graph field is correctly added to ExecutionContext with a safe default of False. This ensures that existing graphs (non-AI-generated) won't unexpectedly require human review, maintaining backward compatibility.

autogpt_platform/backend/backend/api/model.py (1)

43-46: LGTM!

The is_ai_generated field is correctly added to the CreateGraph API model with a default of False, ensuring backward compatibility with existing API consumers.

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

64-75: LGTM!

The GraphSettings.from_graph() classmethod provides a clean factory pattern for constructing settings from a graph. The logic correctly:

  • Sets human_in_the_loop_safe_mode to True when the graph has HITL blocks, or None otherwise (allowing default behavior)
  • Propagates the is_ai_generated flag into the settings

This consolidates the previously duplicated initialization logic mentioned in the PR objectives.

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

640-645: Verify the behavioral change for existing workflows.

The review logic now requires all three conditions to trigger a human review pause:

  1. self.requires_human_review is True
  2. execution_context.safe_mode is True
  3. execution_context.is_ai_generated_graph is True

This means blocks with requires_human_review=True in human-created graphs (is_ai_generated_graph=False) will no longer pause for review, even with safe_mode=True. This is a behavioral change from the previous logic.

Per the PR objectives, this is intentional: "blocks with required_human_review now pause for review only when both safe_mode=True and is_ai_generated_graph=True". Please confirm this is the desired behavior for existing users who may rely on human review for non-AI-generated graphs.

autogpt_platform/backend/backend/executor/utils.py (1)

874-885: LGTM!

The is_ai_generated_graph flag is correctly propagated from GraphSettings into the ExecutionContext. This completes the data flow:

  1. GraphSettings.from_graph() captures the flag during library agent creation
  2. get_graph_settings() retrieves it from the database
  3. add_graph_execution() passes it to ExecutionContext
  4. Block execution uses it in the review logic

The implementation correctly integrates with the existing safe_mode and user_timezone context setup.

autogpt_platform/backend/backend/api/features/v1.py (2)

766-768: LGTM!

The is_ai_generated flag is correctly propagated from the CreateGraph request to the library agent creation flow.


923-927: LGTM!

The update_graph_settings endpoint correctly passes user-provided settings to update_library_agent using the proper library_agent_id parameter.

autogpt_platform/backend/backend/api/features/library/db.py (3)

404-418: LGTM!

The new is_ai_generated parameter is well-documented and has a sensible default value.


451-455: LGTM!

The is_ai_generated flag is correctly propagated through GraphSettings.from_graph() and serialized for database storage.


799-801: LGTM!

Using the default is_ai_generated=False for store agents is appropriate since marketplace agents are not considered AI-generated.

Comment thread autogpt_platform/backend/backend/api/features/v1.py Outdated
When updating a library agent to a new version, the is_ai_generated_graph
flag was being reset to False (the default), disabling human review for
AI-generated graphs on subsequent runs.

Fix: Pass the existing is_ai_generated_graph value from library.settings
to GraphSettings.from_graph() to preserve the flag across version updates.

Uses from_graph() to reduce duplication while preserving all settings.
@majdyz
majdyz force-pushed the feat/ai-generated-mode branch from c22a347 to 8d3dfe2 Compare January 12, 2026 21:22
…ettings.from_graph()

- Removed default value from is_ai_generated parameter
- Forces all callers to explicitly specify whether graph is AI-generated
- Explicitly set is_ai_generated=False for store installations (curated user-published agents)
- Makes the code more explicit and prevents accidental defaults
@majdyz

majdyz commented Jan 12, 2026

Copy link
Copy Markdown
Contributor Author

🔧 Refactoring: Made is_ai_generated parameter mandatory

Made the is_ai_generated parameter mandatory (removed default) in GraphSettings.from_graph() to force explicit decisions at each call site.

Changes:

# Before
def from_graph(cls, graph: GraphModel, is_ai_generated: bool = False)

# After  
def from_graph(cls, graph: GraphModel, is_ai_generated: bool)  # ✅ No default

Call Sites:

  1. User creates graph (create_new_graph): Uses create_graph.is_ai_generated from API
  2. Version activation (_update_library_agent_version_and_settings): Preserves library.settings.is_ai_generated_graph
  3. Store installation (add_store_agent_to_library): Explicitly is_ai_generated=False (store agents are curated user-published content)

This makes the code more explicit and prevents accidental defaults. Every caller must consciously decide the value.

Comment thread autogpt_platform/backend/backend/api/features/library/db.py
…er mandatory

- Fix bug where forking a library agent would reset is_ai_generated_graph to False
  - Now preserves the original agent's is_ai_generated_graph flag
  - Ensures forked AI-generated agents maintain safety requirements

- Make is_ai_generated parameter mandatory in create_library_agent()
  - Moved parameter before optional parameters for consistency
  - Removed default value to force explicit decisions at all call sites
  - Updated all 4 call sites to explicitly pass the parameter

- Update snapshot test for new is_ai_generated_graph field in settings

All 33 tests passing
@majdyz

majdyz commented Jan 12, 2026

Copy link
Copy Markdown
Contributor Author

✅ Additional fixes pushed

Bug Fix: Fork preserves is_ai_generated_graph

  • Fixed critical bug where forking a library agent would reset is_ai_generated_graph to False
  • Forked agents now correctly preserve the original agent's safety settings

Refactoring: Mandatory parameter

  • Made is_ai_generated parameter mandatory in create_library_agent()
  • Moved parameter before optional parameters for better API design
  • Updated all 4 call sites to explicitly pass the parameter:
    • API creation: Uses value from request
    • Fork: Preserves from original agent
    • Chat tools: Defaults to False (user-executed)
    • Test data: Defaults to False

Testing

✅ All 33 tests passing
✅ Snapshot test updated
✅ Code formatted and type-checked

Commit: eef7cf8

- Add is_ai_generated field to CreateGraph model
- Add is_ai_generated_graph field to GraphSettings model
- Sync frontend API schema with backend changes
@github-actions github-actions Bot added the platform/frontend AutoGPT Platform - Front end label Jan 12, 2026

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

Caution

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

⚠️ Outside diff range comments (2)
autogpt_platform/frontend/src/app/api/openapi.json (2)

6608-6626: Regenerate the frontend API client/hooks to pick up CreateGraph.is_ai_generated and GraphSettings.is_ai_generated_graph.

Per coding guidelines, this OpenAPI spec change requires running pnpm generate:api to update the TypeScript client. These new boolean fields (both optional with default: false) won't be available in generated types/hooks until regeneration completes.

Consider adding a description field to document intent—especially for the settings field's interaction with safe mode:

Proposed schema improvement
           "is_ai_generated": {
             "type": "boolean",
             "title": "Is Ai Generated",
+            "description": "Whether this graph was AI-generated. Used to conditionally enable human review behavior when safe mode is enabled.",
             "default": false
           }
           "is_ai_generated_graph": {
             "type": "boolean",
             "title": "Is Ai Generated Graph",
+            "description": "Flag indicating whether the graph settings apply to an AI-generated graph. Used for gating review behavior in safe mode.",
             "default": false
           }

7561-7575: Backend PATCH endpoint for graph settings needs proper merge semantics to avoid resetting is_ai_generated_graph to false.

The OpenAPI schema defines is_ai_generated_graph with a default value of false. The backend endpoint accepts the full GraphSettings object and saves it directly (v1.py:913-931). When the frontend sends a partial update like { human_in_the_loop_safe_mode: true }, Pydantic deserializes it into a complete GraphSettings object with is_ai_generated_graph defaulting to false, which then overwrites any previously set true value in the database.

Recommend either:

  1. Change the backend to only update fields explicitly provided in the request (JSON merge semantics), or
  2. Define all schema fields as Optional and validate on the backend to reject null submissions.

The current frontend code (useAgentSafeMode.ts) is safe because it's the only call site, but the API schema permits this problem for other potential callers.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between eef7cf8 and 4eac081.

📒 Files selected for processing (1)
  • autogpt_platform/frontend/src/app/api/openapi.json
🧰 Additional context used
📓 Path-based instructions (2)
autogpt_platform/frontend/**/*.{ts,tsx,json}

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

Use Node.js 21+ with pnpm package manager for frontend development

Files:

  • autogpt_platform/frontend/src/app/api/openapi.json
autogpt_platform/frontend/**

📄 CodeRabbit inference engine (autogpt_platform/CLAUDE.md)

autogpt_platform/frontend/**: Install frontend dependencies using pnpm i instead of npm
Generate API client from OpenAPI spec using pnpm generate:api
Regenerate API client hooks using pnpm generate:api when OpenAPI spec changes

Files:

  • autogpt_platform/frontend/src/app/api/openapi.json
⏰ 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: types
  • GitHub Check: test
  • GitHub Check: chromatic
  • GitHub Check: Seer Code Review
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.12)
  • GitHub Check: Check PR Status

@majdyz
majdyz enabled auto-merge January 12, 2026 22:51
@majdyz
majdyz requested a review from ntindle January 13, 2026 18:58
ntindle
ntindle previously approved these changes Jan 16, 2026
@majdyz
majdyz added this pull request to the merge queue Jan 16, 2026
Comment thread autogpt_platform/backend/backend/api/features/library/db.py
@majdyz majdyz changed the title feat(backend,frontend): replace is_ai_generated with two explicit safe mode toggles feat(backend,frontend): add explicit safe mode toggles for HITL and sensitive actions Jan 19, 2026
When forking a library agent, the human_in_the_loop_safe_mode setting
was not being preserved from the original agent. This fix adds the
hitl_safe_mode parameter to create_library_agent and passes it in
fork_library_agent to ensure both safe mode settings are preserved.
… actions

Refactored FloatingSafeModeToggle and SafeModeToggle components to:
- Show individual badges for HITL and sensitive action approval
- Only display badges for the relevant toggle type (HITL-only, sensitive-only, or both)
- Use consistent labels with the settings modal ("Human-in-the-loop approval", "Sensitive action approval")
- Add tooltips with descriptive text for each toggle state

@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

🤖 Fix all issues with AI agents
In
`@autogpt_platform/frontend/src/app/`(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx:
- Around line 39-51: The Button in SafeModeToggle is given opacity-0 when
isPending which hides it visually but leaves it interactive; update the
SafeModeToggle component to pass disabled={isPending} to the Button (same
pattern used in FloatingSafeModeToggle) and ensure any click handler (onToggle)
will not fire when disabled; also keep or adjust the cn(...) class usage to
reflect disabled styling if needed so the element is neither focusable nor
clickable while pending.
🧹 Nitpick comments (4)
autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx (2)

98-100: Early return hides UI during pending state.

Returning null when isPending hides the entire toggle section during mutations. This differs from SafeModeToggle.tsx which keeps buttons visible (using opacity). Consider whether hiding vs showing a disabled state provides better UX consistency.

If hiding is intentional (e.g., to prevent layout shift or confusion), this is fine. Otherwise, consider aligning behavior with the sibling component.


81-135: Filename typo: "Toogle" should be "Toggle".

The filename FloatingSafeModeToogle.tsx contains a typo. This could cause confusion and import inconsistencies. Consider renaming to FloatingSafeModeToggle.tsx.

autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx (2)

4-4: Deprecated import path.

Same issue as the other file—@/lib/autogpt-server-api/types appears deprecated. Consider using generated types from @/app/api/__generated__/.


80-85: Redundant !isHITLStateUndetermined check.

Line 80 already returns early if isHITLStateUndetermined is true, so the check on line 84 is always true and can be simplified:

Proposed simplification
-  const showHITL = showHITLToggle && !isHITLStateUndetermined;
+  const showHITL = showHITLToggle;
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between af14fb6 and 60babcd.

📒 Files selected for processing (2)
  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
🧰 Additional context used
📓 Path-based instructions (8)
autogpt_platform/frontend/**/*.{ts,tsx}

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

autogpt_platform/frontend/**/*.{ts,tsx}: Always run pnpm install before frontend development, then use pnpm dev to start development server on port 3000
For frontend code formatting and linting, always run pnpm format

If adding protected frontend routes, update frontend/lib/supabase/middleware.ts

autogpt_platform/frontend/**/*.{ts,tsx}: Use generated API hooks from @/app/api/__generated__/endpoints/ for data fetching in frontend
Use function declarations (not arrow functions) for components and handlers in frontend
Only use Phosphor Icons in frontend; never use other icon libraries
Never use src/components/__legacy__/* or deprecated BackendAPI in frontend

Files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
autogpt_platform/frontend/**/*.{ts,tsx,json}

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

Use Node.js 21+ with pnpm package manager for frontend development

Files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
autogpt_platform/frontend/src/**/*.{ts,tsx}

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

autogpt_platform/frontend/src/**/*.{ts,tsx}: Use generated API hooks from @/app/api/__generated__/endpoints/ (generated via Orval from backend OpenAPI spec). Pattern: use{Method}{Version}{OperationName} (e.g., useGetV2ListLibraryAgents). Regenerate with: pnpm generate:api. Never use deprecated BackendAPI or src/lib/autogpt-server-api/*
Use function declarations for components and handlers (not arrow functions). Only arrow functions for small inline lambdas (map, filter, etc.)
Use PascalCase for components, camelCase with use prefix for hooks
No barrel files or index.ts re-exports in frontend
For frontend render errors, use component. For mutation errors, display with toast notifications. For manual exceptions, use Sentry.captureException()
Default to client components (use client). Use server components only for SEO or extreme TTFB needs. Use React Query for server state via generated hooks. Co-locate UI state in components/hooks

Files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
autogpt_platform/frontend/**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Format frontend code using pnpm format

Files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
autogpt_platform/frontend/**

📄 CodeRabbit inference engine (autogpt_platform/CLAUDE.md)

autogpt_platform/frontend/**: Install frontend dependencies using pnpm i instead of npm
Generate API client from OpenAPI spec using pnpm generate:api
Regenerate API client hooks using pnpm generate:api when OpenAPI spec changes

Files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
autogpt_platform/frontend/src/**/*.tsx

📄 CodeRabbit inference engine (autogpt_platform/CLAUDE.md)

Use design system components from src/components/ (atoms, molecules, organisms) in frontend

Files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
autogpt_platform/frontend/src/app/**/*.tsx

📄 CodeRabbit inference engine (autogpt_platform/CLAUDE.md)

Create frontend pages in src/app/(platform)/feature-name/page.tsx with corresponding usePageName.ts hook and local components/ subfolder

Files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
autogpt_platform/frontend/**/*.{ts,tsx,css}

📄 CodeRabbit inference engine (autogpt_platform/CLAUDE.md)

Use only Tailwind CSS for styling in frontend, with design tokens and Phosphor Icons

Files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
🧠 Learnings (4)
📚 Learning: 2025-11-25T08:48:33.246Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T08:48:33.246Z
Learning: Applies to autogpt_platform/frontend/src/components/**/*.tsx : Separate frontend component render logic from data/behavior. Structure: ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts. Small components (3-4 lines) can be inline. Render-only components can be direct files without folders

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
📚 Learning: 2025-11-25T08:48:33.246Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T08:48:33.246Z
Learning: Applies to autogpt_platform/frontend/src/**/*.{ts,tsx} : Use PascalCase for components, camelCase with use prefix for hooks

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
  • autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx
📚 Learning: 2025-11-25T08:49:03.583Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/CLAUDE.md:0-0
Timestamp: 2025-11-25T08:49:03.583Z
Learning: Applies to autogpt_platform/frontend/src/components/**/*.{ts,tsx} : Structure frontend components as `ComponentName/ComponentName.tsx` plus `useComponentName.ts` hook plus `helpers.ts` file

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
📚 Learning: 2025-11-25T08:48:33.246Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T08:48:33.246Z
Learning: Applies to autogpt_platform/frontend/src/components/**/*.tsx : Prefer design tokens over hardcoded values in frontend styling

Applied to files:

  • autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx
🧬 Code graph analysis (1)
autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx (3)
autogpt_platform/frontend/src/components/atoms/Tooltip/BaseTooltip.tsx (3)
  • Tooltip (40-40)
  • TooltipTrigger (40-40)
  • TooltipContent (40-40)
autogpt_platform/frontend/src/components/atoms/Button/Button.tsx (1)
  • Button (12-152)
autogpt_platform/frontend/src/hooks/useAgentSafeMode.ts (1)
  • useAgentSafeMode (41-206)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: types
  • GitHub Check: test
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.13)
  • GitHub Check: Check PR Status
🔇 Additional comments (3)
autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsx (2)

21-79: Well-structured internal component.

The SafeModeButton component is clean, reusable, and properly handles:

  • Tooltip with clear enabled/disabled messaging
  • Visual state differentiation via variant and text color
  • Disabled state during pending operations
  • Accessible labeling via Button content

4-4: [rewritten comment]
[classification tag]

autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/selected-views/SelectedRunView/components/SafeModeToggle.tsx (1)

67-115: Component structure follows conventions.

The refactored SafeModeToggle cleanly separates concerns with the internal SafeModeIconButton, uses proper conditional rendering, and maintains the same public signature. Good use of tooltips for user guidance.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Button was visually hidden with opacity-0 during pending state but still
interactive, allowing accidental keyboard/click interactions. Added
disabled={isPending} to match pattern in FloatingSafeModeToggle.
@majdyz
majdyz disabled auto-merge January 21, 2026 00:43
@majdyz
majdyz enabled auto-merge January 21, 2026 00:43
Comment thread autogpt_platform/backend/backend/data/execution.py
Comment thread autogpt_platform/backend/backend/data/graph.py
Comment thread autogpt_platform/backend/backend/api/features/library/db.py
Comment thread autogpt_platform/backend/backend/executor/utils.py
Comment thread autogpt_platform/backend/backend/blocks/human_in_the_loop.py
Comment thread autogpt_platform/backend/backend/blocks/helpers/review.py
Comment thread autogpt_platform/backend/backend/data/graph.py
Comment thread autogpt_platform/backend/backend/api/features/v1.py
@majdyz

majdyz commented Jan 21, 2026

Copy link
Copy Markdown
Contributor Author

Re: is_ai_generated_graph comments

These comments are false positives. The is_ai_generated_graph field does not exist in GraphSettings. The model only has:

  • human_in_the_loop_safe_mode: bool = True
  • sensitive_action_safe_mode: bool = False

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

Projects

Status: ✅ Done
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants