Skip to content

feat: added resource gates for automations#1446

Merged
MODSetter merged 2 commits into
devfrom
dev_mod
May 29, 2026
Merged

feat: added resource gates for automations#1446
MODSetter merged 2 commits into
devfrom
dev_mod

Conversation

@MODSetter
Copy link
Copy Markdown
Owner

@MODSetter MODSetter commented May 29, 2026

Description

Motivation and Context

FIX #

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR implements resource gates for automations to ensure they only run on billable models (premium global configurations or user-provided BYOK models). It introduces a model policy enforcement system that blocks automations from using free models or Auto mode, captures model configurations at creation time to insulate runs from later changes, and adds both backend validation and frontend UI gating. The implementation includes a new /automations/model-eligibility endpoint, model snapshot preservation in automation definitions, runtime enforcement in agent task dependencies, and comprehensive frontend alerts/disabled states when model requirements aren't met.

⏱️ Estimated Review Time: 1-3 hours

💡 Review Order Suggestion
Order File Path
1 surfsense_backend/app/automations/services/model_policy.py
2 surfsense_backend/app/automations/schemas/definition/envelope.py
3 surfsense_backend/app/automations/schemas/definition/__init__.py
4 surfsense_backend/app/automations/actions/types.py
5 surfsense_backend/app/automations/api/automation.py
6 surfsense_backend/app/automations/services/automation.py
7 surfsense_backend/app/automations/services/__init__.py
8 surfsense_backend/app/automations/runtime/executor.py
9 surfsense_backend/app/automations/actions/agent_task/dependencies.py
10 surfsense_backend/app/automations/actions/agent_task/invoke.py
11 surfsense_backend/app/agents/multi_agent_chat/main_agent/tools/automation/create.py
12 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/deliverables/tools/generate_image.py
13 surfsense_backend/app/agents/multi_agent_chat/subagents/builtins/deliverables/tools/index.py
14 surfsense_backend/app/agents/multi_agent_chat/main_agent/runtime/factory.py
15 surfsense_backend/app/agents/multi_agent_chat/main_agent/runtime/agent_cache.py
16 surfsense_backend/tests/unit/automations/services/test_model_policy.py
17 surfsense_backend/tests/unit/automations/services/test_automation_service_policy.py
18 surfsense_backend/tests/unit/automations/actions/agent_task/test_dependencies.py
19 surfsense_backend/tests/unit/automations/runtime/test_executor_action_ctx.py
20 surfsense_backend/tests/unit/automations/schemas/definition/test_envelope.py
21 surfsense_backend/tests/unit/automations/services/__init__.py
22 surfsense_web/contracts/types/automation.types.ts
23 surfsense_web/hooks/use-automation-model-eligibility.ts
24 surfsense_web/lib/apis/automations-api.service.ts
25 surfsense_web/lib/query-client/cache-keys.ts
26 surfsense_web/app/dashboard/[search_space_id]/automations/components/automation-model-gate-alert.tsx
27 surfsense_web/app/dashboard/[search_space_id]/automations/components/automations-empty-state.tsx
28 surfsense_web/app/dashboard/[search_space_id]/automations/components/automations-header.tsx
29 surfsense_web/app/dashboard/[search_space_id]/automations/components/builder/automation-builder-form.tsx
30 surfsense_web/app/dashboard/[search_space_id]/automations/new/automation-new-content.tsx
31 surfsense_web/app/dashboard/[search_space_id]/automations/automations-content.tsx
32 surfsense_web/components/settings/llm-role-manager.tsx
33 surfsense_web/atoms/new-llm-config/new-llm-config-mutation.atoms.ts

Need help? Join our Discord

MODSetter added 2 commits May 29, 2026 03:13
…creation

- Added model eligibility checks to ensure automations can only use billable models (premium or BYOK).
- Introduced new API endpoint to report model eligibility status for search spaces.
- Updated frontend components to display eligibility alerts and disable creation options when models are not billable.
- Enhanced automation creation forms to reflect model eligibility, preventing users from submitting invalid configurations.
- Implemented server-side logic to capture and preserve model preferences across automation edits, ensuring consistent behavior during execution.
- Added useEffect to sync local assignments state with preferences when they change, ensuring the UI reflects the latest data.
- Updated state initialization to use null instead of empty strings for clarity in role assignments.
- Adjusted role assignment handling to correctly manage "unassigned" values and preserve Auto mode configuration during updates.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
surf-sense-frontend Ready Ready Preview, Comment May 29, 2026 7:32pm

Request Review

@MODSetter MODSetter merged commit cb2e33e into dev May 29, 2026
6 of 10 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9e7a7e0d-4fa5-4039-a01f-2f227e69ea91

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev_mod

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant