fix: page ready agents during health-check startup#345
Open
scale-sf wants to merge 2 commits into
Open
Conversation
8586b34 to
dd0e73d
Compare
Author
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Tests
Greptile Summary
This PR replaces a full-table
agent_repo.list()call (loaded all agents and filtered in Python) with a stable, paginated query that applies theREADYstatus filter at the database level. A newREADY_AGENT_PAGE_SIZE = 200constant drives the loop, which exits on either an empty page or a partial page.run_healthcheck_workflow.pynow passesfilters={\"status\": AgentStatus.READY},order_by=\"id\", andorder_direction=\"asc\"to the repository, giving deterministic offset-based pagination with no Python-side status filtering.while Trueloop.Confidence Score: 5/5
Safe to merge — the change is a well-scoped correctness improvement to startup logic with no side-effects beyond health-check workflow registration.
The pagination loop is logically correct: it exits on an empty page or a partial page, starts at page 1 (matching the 1-based offset formula (page_number - 1) * limit in the base repository), and passes order_by=id which resolves to a stable, unique primary-key sort in create_order_by_clauses. The status filter is applied at the DB layer and confirmed reachable through create_where_clauses_from_filters. Both boundary conditions (exact multiple and partial remainder) are covered by the new tests.
No files require special attention.
Important Files Changed
Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant Main as run_healthcheck_workflow.main() participant Repo as AgentRepository participant DB as PostgreSQL participant Temporal as TemporalAdapter Main->>Repo: "list(filters={status: READY}, limit=200, page_number=1, order_by="id")" Repo->>DB: "SELECT ... WHERE status=READY ORDER BY id ASC LIMIT 200 OFFSET 0" DB-->>Repo: agents[0..199] Repo-->>Main: agents (200 items) loop For each agent on page 1 Main->>Temporal: "start_workflow(healthcheck_workflow_{agent.id})" end Main->>Repo: "list(..., page_number=2)" Repo->>DB: SELECT ... LIMIT 200 OFFSET 200 DB-->>Repo: agents[200..N] Repo-->>Main: "agents (< 200 or empty)" loop For each agent on page 2 Main->>Temporal: "start_workflow(healthcheck_workflow_{agent.id})" end Note over Main: Break on empty page or len(agents) < 200%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant Main as run_healthcheck_workflow.main() participant Repo as AgentRepository participant DB as PostgreSQL participant Temporal as TemporalAdapter Main->>Repo: "list(filters={status: READY}, limit=200, page_number=1, order_by="id")" Repo->>DB: "SELECT ... WHERE status=READY ORDER BY id ASC LIMIT 200 OFFSET 0" DB-->>Repo: agents[0..199] Repo-->>Main: agents (200 items) loop For each agent on page 1 Main->>Temporal: "start_workflow(healthcheck_workflow_{agent.id})" end Main->>Repo: "list(..., page_number=2)" Repo->>DB: SELECT ... LIMIT 200 OFFSET 200 DB-->>Repo: agents[200..N] Repo-->>Main: "agents (< 200 or empty)" loop For each agent on page 2 Main->>Temporal: "start_workflow(healthcheck_workflow_{agent.id})" end Note over Main: Break on empty page or len(agents) < 200Reviews (4): Last reviewed commit: "Merge branch 'main' into fix/page-ready-..." | Re-trigger Greptile