feat(backend,frontend): add explicit safe mode toggles for HITL and sensitive actions - #11756
Conversation
…_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)
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📒 Files selected for processing (5)
Note Other AI code review bot(s) detectedCodeRabbit 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. WalkthroughSplit 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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ 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. Comment |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
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.
📒 Files selected for processing (7)
autogpt_platform/backend/backend/api/features/library/db.pyautogpt_platform/backend/backend/api/features/v1.pyautogpt_platform/backend/backend/api/model.pyautogpt_platform/backend/backend/data/block.pyautogpt_platform/backend/backend/data/execution.pyautogpt_platform/backend/backend/data/graph.pyautogpt_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, andpoetry run lint(ruff) to check remaining errors
Files:
autogpt_platform/backend/backend/api/model.pyautogpt_platform/backend/backend/data/block.pyautogpt_platform/backend/backend/executor/utils.pyautogpt_platform/backend/backend/data/execution.pyautogpt_platform/backend/backend/data/graph.pyautogpt_platform/backend/backend/api/features/library/db.pyautogpt_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.pyautogpt_platform/backend/backend/data/block.pyautogpt_platform/backend/backend/executor/utils.pyautogpt_platform/backend/backend/data/execution.pyautogpt_platform/backend/backend/data/graph.pyautogpt_platform/backend/backend/api/features/library/db.pyautogpt_platform/backend/backend/api/features/v1.py
autogpt_platform/backend/**
📄 CodeRabbit inference engine (autogpt_platform/CLAUDE.md)
autogpt_platform/backend/**: Install dependencies for backend usingpoetry install
Run database migrations usingpoetry run prisma migrate dev
Files:
autogpt_platform/backend/backend/api/model.pyautogpt_platform/backend/backend/data/block.pyautogpt_platform/backend/backend/executor/utils.pyautogpt_platform/backend/backend/data/execution.pyautogpt_platform/backend/backend/data/graph.pyautogpt_platform/backend/backend/api/features/library/db.pyautogpt_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.pyautogpt_platform/backend/backend/data/execution.pyautogpt_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.pyautogpt_platform/backend/backend/data/execution.pyautogpt_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_graphfield is correctly added toExecutionContextwith a safe default ofFalse. 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_generatedfield is correctly added to theCreateGraphAPI model with a default ofFalse, 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_modetoTruewhen the graph has HITL blocks, orNoneotherwise (allowing default behavior)- Propagates the
is_ai_generatedflag into the settingsThis 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:
self.requires_human_reviewis Trueexecution_context.safe_modeis Trueexecution_context.is_ai_generated_graphis TrueThis means blocks with
requires_human_review=Truein human-created graphs (is_ai_generated_graph=False) will no longer pause for review, even withsafe_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_graphflag is correctly propagated fromGraphSettingsinto theExecutionContext. This completes the data flow:
GraphSettings.from_graph()captures the flag during library agent creationget_graph_settings()retrieves it from the databaseadd_graph_execution()passes it toExecutionContext- Block execution uses it in the review logic
The implementation correctly integrates with the existing
safe_modeanduser_timezonecontext setup.autogpt_platform/backend/backend/api/features/v1.py (2)
766-768: LGTM!The
is_ai_generatedflag is correctly propagated from theCreateGraphrequest to the library agent creation flow.
923-927: LGTM!The
update_graph_settingsendpoint correctly passes user-provided settings toupdate_library_agentusing the properlibrary_agent_idparameter.autogpt_platform/backend/backend/api/features/library/db.py (3)
404-418: LGTM!The new
is_ai_generatedparameter is well-documented and has a sensible default value.
451-455: LGTM!The
is_ai_generatedflag is correctly propagated throughGraphSettings.from_graph()and serialized for database storage.
799-801: LGTM!Using the default
is_ai_generated=Falsefor store agents is appropriate since marketplace agents are not considered AI-generated.
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.
c22a347 to
8d3dfe2
Compare
…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
🔧 Refactoring: Made
|
…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
✅ Additional fixes pushedBug Fix: Fork preserves
|
- Add is_ai_generated field to CreateGraph model - Add is_ai_generated_graph field to GraphSettings model - Sync frontend API schema with backend changes
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
autogpt_platform/frontend/src/app/api/openapi.json (2)
6608-6626: Regenerate the frontend API client/hooks to pick upCreateGraph.is_ai_generatedandGraphSettings.is_ai_generated_graph.Per coding guidelines, this OpenAPI spec change requires running
pnpm generate:apito update the TypeScript client. These new boolean fields (both optional withdefault: false) won't be available in generated types/hooks until regeneration completes.Consider adding a
descriptionfield 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 resettingis_ai_generated_graphtofalse.The OpenAPI schema defines
is_ai_generated_graphwith a default value offalse. The backend endpoint accepts the fullGraphSettingsobject 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 completeGraphSettingsobject withis_ai_generated_graphdefaulting tofalse, which then overwrites any previously settruevalue in the database.Recommend either:
- Change the backend to only update fields explicitly provided in the request (JSON merge semantics), or
- Define all schema fields as
Optionaland 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.
📒 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 usingpnpm iinstead of npm
Generate API client from OpenAPI spec usingpnpm generate:api
Regenerate API client hooks usingpnpm generate:apiwhen 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
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
There was a problem hiding this comment.
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
nullwhenisPendinghides the entire toggle section during mutations. This differs fromSafeModeToggle.tsxwhich 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.tsxcontains a typo. This could cause confusion and import inconsistencies. Consider renaming toFloatingSafeModeToggle.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/typesappears deprecated. Consider using generated types from@/app/api/__generated__/.
80-85: Redundant!isHITLStateUndeterminedcheck.Line 80 already returns early if
isHITLStateUndeterminedis 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.
📒 Files selected for processing (2)
autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsxautogpt_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 formatIf 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 usesrc/components/__legacy__/*or deprecatedBackendAPIin frontend
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsxautogpt_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.tsxautogpt_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.tsxautogpt_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.tsxautogpt_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 usingpnpm iinstead of npm
Generate API client from OpenAPI spec usingpnpm generate:api
Regenerate API client hooks usingpnpm generate:apiwhen OpenAPI spec changes
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsxautogpt_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.tsxautogpt_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.tsxwith correspondingusePageName.tshook and localcomponents/subfolder
Files:
autogpt_platform/frontend/src/app/(platform)/build/components/FloatingSafeModeToogle.tsxautogpt_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.tsxautogpt_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.tsxautogpt_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.tsxautogpt_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
SafeModeButtoncomponent 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
SafeModeTogglecleanly separates concerns with the internalSafeModeIconButton, 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.
|
Re: is_ai_generated_graph comments These comments are false positives. The
|
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, defaulttrue) - Controls whether human-in-the-loop (HITL) blocks pause for reviewsensitive_action_safe_mode(bool, defaultfalse) - Controls whether sensitive action blocks pause for reviewNew Computed Properties on LibraryAgent:
has_human_in_the_loop- Indicates if agent contains HITL blockshas_sensitive_action- Indicates if agent contains sensitive action blocksBlock Changes:
requires_human_reviewtois_sensitive_actionon blocks for clarityis_sensitive_action=Truepause only whensensitive_action_safe_mode=Truehuman_in_the_loop_safe_mode=TrueFrontend Changes:
has_human_in_the_loopandhas_sensitive_actioncomputed propertiesAI-Generated Agent Behavior:
sensitive_action_safe_mode=Trueby defaultChanges
Backend:
backend/data/graph.py- UpdatedGraphSettingswith two boolean toggles (non-optional with defaults), addedhas_sensitive_actioncomputed propertybackend/data/block.py- Renamedrequires_human_reviewtois_sensitive_action, updated review logicbackend/data/execution.py- UpdatedExecutionContextwith both safe mode fieldsbackend/api/features/library/model.py- Addedhas_human_in_the_loopandhas_sensitive_actiontoLibraryAgentbackend/api/features/library/db.py- Updated to usesensitive_action_safe_modeparameterbackend/executor/utils.py- Simplified execution context creationFrontend:
useAgentSafeMode.ts- Rewritten to support two independent togglesAgentSettingsModal.tsx- Shows two separate togglesSelectedSettingsView.tsx- Shows two separate togglesTest Plan