Cron: Add mode: direct for callback-style jobs #46

Open
opened 2026-02-20 17:24:13 +00:00 by doxios · 0 comments
Collaborator

Summary

Extend the cron plugin to support direct plugin method calls without LLM.

Split from #3 (Logbot infrastructure).

Current Behavior

Cron jobs are prompts executed by the LLM:

cron:
  jobs:
    - name: daily-report
      schedule: "0 9 * * *"
      mode: isolated      # or main_session
      prompt: "Generate daily report"

Proposed Addition

Add mode: direct for calling plugin methods directly:

cron:
  jobs:
    - name: commit-archive
      schedule: "0 */12 * * *"
      mode: direct
      action: git.commit_and_push   # plugin_id.method_name
      args:
        paths: ["./archive"]
        message: "chore: archive sync"

Implementation

async def _run_direct_job(self, job: CronJob) -> None:
    plugin_id, method_name = job.action.split(".")
    plugin = self._registry.get(plugin_id)
    if plugin and hasattr(plugin, method_name):
        method = getattr(plugin, method_name)
        result = await method(**job.args) if asyncio.iscoroutinefunction(method) else method(**job.args)
        await self._route_output(job, str(result))

Use Cases

  • Git commits on schedule (no LLM needed)
  • Database cleanup
  • Log rotation
  • Any plugin method that should run periodically

Why Not Just Use mode: isolated?

  • isolated requires LLM — costs money, slower
  • direct is instant, no LLM call
  • Essential for "logbot" pattern (no LLM at all)
  • #3 (original logbot issue)
  • #35 (scheduled execution architecture)
  • #45 (git plugin needs this)
## Summary Extend the cron plugin to support direct plugin method calls without LLM. Split from #3 (Logbot infrastructure). ## Current Behavior Cron jobs are prompts executed by the LLM: ```yaml cron: jobs: - name: daily-report schedule: "0 9 * * *" mode: isolated # or main_session prompt: "Generate daily report" ``` ## Proposed Addition Add `mode: direct` for calling plugin methods directly: ```yaml cron: jobs: - name: commit-archive schedule: "0 */12 * * *" mode: direct action: git.commit_and_push # plugin_id.method_name args: paths: ["./archive"] message: "chore: archive sync" ``` ## Implementation ```python async def _run_direct_job(self, job: CronJob) -> None: plugin_id, method_name = job.action.split(".") plugin = self._registry.get(plugin_id) if plugin and hasattr(plugin, method_name): method = getattr(plugin, method_name) result = await method(**job.args) if asyncio.iscoroutinefunction(method) else method(**job.args) await self._route_output(job, str(result)) ``` ## Use Cases - Git commits on schedule (no LLM needed) - Database cleanup - Log rotation - Any plugin method that should run periodically ## Why Not Just Use `mode: isolated`? - `isolated` requires LLM — costs money, slower - `direct` is instant, no LLM call - Essential for "logbot" pattern (no LLM at all) ## Related - #3 (original logbot issue) - #35 (scheduled execution architecture) - #45 (git plugin needs this)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ultanio/cobot#46
No description provided.