feat: add scheduled execution plugins (subagent, cron, heartbeat) #42
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Competitor
Kind/Documentation
Kind/Enhancement
Kind/Epic
Kind/Feature
Kind/Security
Kind/Story
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Scope/Core
Scope/Cross-Plugin
Scope/Plugin-System
Scope/Single-Plugin
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ultanio/cobot!42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/scheduled-execution"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements the scheduled execution architecture from #35.
Extension Points
Provided (defined by these plugins)
subagent.before_spawnsubagent.after_spawncron.before_jobcron.after_jobImplemented (hooks into other plugins)
session.poll_messagespoll_main_session_jobsmain_sessionjobs into the loopPlugins Added
1. Subagent Plugin (
cobot/plugins/subagent/)subagent,toolsspawn_subagentfor agent useSubagentProvider.spawn()for plugin usecobot subagent spawn <task>,cobot subagent status2. Cron Plugin (
cobot/plugins/cron/)cron,toolsisolated: spawns subagent (no context)main_session: injects into main session (full context)cron_add_job,cron_remove_job,cron_list_jobscobot cron list,cobot cron add,cobot cron remove,cobot cron run3. Heartbeat Plugin (
cobot/plugins/heartbeat/)cronenabled,interval_minutes,prompt_filemode: main_sessionArchitecture
Key principles:
session.poll_messagesextension pointmode: main_sessionConfig Examples
CLI Commands
Tests
tests/test_scheduled.py(3 new integration tests)Closes #35
Fix Applied ✅
Issues Found & Fixed
1. Critical:
session.poll_messagesnot wiredsession.poll_messagesextension pointmain_sessionjobs are merged into the poll resultscomm.poll()+session.poll_messages()→ merged →loop.on_message2. Medium: Async pattern in SubagentPlugin
asyncio.get_event_loop().run_until_complete()withThreadPoolExecutor+asyncio.run()RuntimeErrorwhen event loop already runningChanges
loop/plugin.py: Added extension point callsubagent/plugin.py: Fixed async executionloop/README.md: Documented new extension pointtest_scheduled.py: Added integration testsReady for Review
CI should re-run. Both issues are fixed.
Bug Fix: Tool Aggregation 🔧
Found the issue - the tools plugin was not aggregating tools from other ToolProvider plugins!
Problem
Solution
Now cron, subagent, knowledge, etc. tools are available to the agent.
Commit:
260b182More Fixes 🔧
Bug 1: Only cron tools visible
Root cause: Loop plugin used
get_by_capability("tools")which returns only the FIRST provider. If the main tools plugin isnt loaded, cron becomes the sole provider.Fix: Added
AggregatedToolProviderclass to loop plugin that collects tools from ALL ToolProviders.Bug 2: Cron job didnt fire
Root cause:
_calculate_next_run()didnt handle* * * * *(every minute). It fell through to 15-minute default.Fix: Added handling for
*minute field → sets next_run to 60 seconds.Commit:
168bb36- Mock all_with_capability('tools') to return tools_plugin (for AggregatedToolProvider) - Mock get_implementations() to return empty list (for call_extension) - Apply ruff formatting to scheduled execution plugins