-
Notifications
You must be signed in to change notification settings - Fork 49
feat(schedules): agent run schedules (v1) #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jromualdez-scale
wants to merge
7
commits into
main
Choose a base branch
from
jerome/scheduled-agents
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,089
−3,446
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
acab2be
feat(schedules): add agent run schedules (v1)
jromualdez-scale 41f8d65
feat(schedules): label scheduled tasks for the UI
jromualdez-scale ec74e5d
docs(schedules): remove internal tracker/design-doc references from c…
jromualdez-scale 9a10531
feat(schedules): address review — idempotency, list perf, update + tr…
jromualdez-scale 6f779eb
feat(schedules): feature-flag the run schedules API (ENABLE_AGENT_RUN…
jromualdez-scale e93b92f
Merge branch 'main' into jerome/scheduled-agents
jromualdez-scale 6bb976a
feat(schedules): enforce text input, drop unused initial_input_method…
jromualdez-scale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
...abase/migrations/alembic/versions/2026_06_22_1200_add_agent_run_schedules_3b1c9d2e4f6a.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| """add agent_run_schedules | ||
|
|
||
| Revision ID: 3b1c9d2e4f6a | ||
| Revises: c7a1b2d3e4f5 | ||
| Create Date: 2026-06-22 12:00:00.000000 | ||
|
|
||
| Creates the agent_run_schedules table backing the scheduled-agent-runs feature. | ||
| Schema-only and idempotent: the table and its indexes are created | ||
| with IF NOT EXISTS-style guards (Alembic create_table on a fresh table), and the | ||
| indexes target the just-created table so they are non-blocking by construction. | ||
| """ | ||
| from collections.abc import Sequence | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = '3b1c9d2e4f6a' | ||
| down_revision: str | None = 'c7a1b2d3e4f5' | ||
| branch_labels: str | Sequence[str] | None = None | ||
| depends_on: str | Sequence[str] | None = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| op.create_table( | ||
| 'agent_run_schedules', | ||
| sa.Column('id', sa.String(), nullable=False), | ||
| sa.Column('agent_id', sa.String(length=64), nullable=False), | ||
| sa.Column('name', sa.String(length=256), nullable=False), | ||
| sa.Column('description', sa.Text(), nullable=True), | ||
| sa.Column('cron_expression', sa.String(), nullable=True), | ||
| sa.Column('interval_seconds', sa.Integer(), nullable=True), | ||
| sa.Column( | ||
| 'timezone', sa.String(), server_default='UTC', nullable=False | ||
| ), | ||
| sa.Column('start_at', sa.DateTime(timezone=True), nullable=True), | ||
| sa.Column('end_at', sa.DateTime(timezone=True), nullable=True), | ||
| sa.Column( | ||
| 'paused', sa.Boolean(), server_default='false', nullable=False | ||
| ), | ||
| sa.Column('creator_principal', sa.JSON(), nullable=False), | ||
| sa.Column('task_params', sa.JSON(), nullable=True), | ||
| sa.Column('task_metadata', sa.JSON(), nullable=True), | ||
| sa.Column('initial_input', sa.JSON(), nullable=False), | ||
| sa.Column( | ||
| 'created_at', | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.text('now()'), | ||
| nullable=True, | ||
| ), | ||
| sa.Column( | ||
| 'updated_at', | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.text('now()'), | ||
| nullable=True, | ||
| ), | ||
| sa.ForeignKeyConstraint(['agent_id'], ['agents.id']), | ||
| sa.PrimaryKeyConstraint('id'), | ||
| ) | ||
| # Indexes target the table created in this same migration, so they hold no | ||
| # write-blocking lock against live traffic (the table has no rows yet). | ||
| op.create_index( | ||
| 'uq_agent_run_schedules_agent_name', | ||
| 'agent_run_schedules', | ||
| ['agent_id', 'name'], | ||
| unique=True, | ||
| ) | ||
| op.create_index( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add an index on updated_at? |
||
| 'idx_agent_run_schedules_agent', | ||
| 'agent_run_schedules', | ||
| ['agent_id'], | ||
| unique=False, | ||
| ) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| op.drop_index('idx_agent_run_schedules_agent', table_name='agent_run_schedules') | ||
| op.drop_index( | ||
| 'uq_agent_run_schedules_agent_name', table_name='agent_run_schedules' | ||
| ) | ||
| op.drop_table('agent_run_schedules') | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a record version field to track every schedule update? Currently, patch, pause, and resume look like blind read-modify-write flows. That means a stale patch could accidentally overwrite a newer pause/resume change and silently reactivate a schedule.
If we add a version number, we can make updates conditional on the version the caller last read. That gives us optimistic concurrency control and also gives us a cleaner audit trail of schedule changes over time.