Repository navigation
Description
Problem or Use Case
GET /v1 can list the automations in one factory with factory_id. A client cannot ask for the automations that are in no factory. To hide factory automations from an org-wide list, the Agent Canvas must list everything and drop rows itself. That leaves short pages and a total that counts rows the client then removes.
Desired Behavior
GET /v1 accepts an in_factory query parameter. false returns only automations in no factory. true returns only automations in a factory. Omitting it returns both, as today. It combines with the other filters, and total follows it.
Acceptance Criteria
-
GET /v1?in_factory=falsereturns only automations in no factory, andtotalcounts only those. -
GET /v1?in_factory=truereturns only automations in a factory. - A request without
in_factoryreturns the same result as before. -
in_factory=falsetogether withfactory_idreturns no rows.
Additional Context
The Agent Canvas change that uses this filter is OpenHands/OpenHands#20074.
This issue was drafted by an AI agent on behalf of the user.
OpenHands AI triage
The following comments and acceptance criteria were added by the OpenHands AI agent.
Triage
GET /v1 (openhands/automation/router.py, list_automations) already applies the caller's org-scoped filters (factory_id, tag, created_by, run_as_user_id) over visible_to, excludes soft-deleted automations, and derives total and offset paging from the same filtered query. The in_factory membership filter belongs in that existing filter chain so total and pagination follow it, as the issue describes.
Bounded scope: an optional boolean in_factory query parameter on this one endpoint, plus automated tests for it. Explicit non-goals: no schema or migration change; no new endpoint; no change to GET /v1/factories counts, visibility rules, ordering, or auth; and no Canvas UI work — the consuming UI is tracked in OpenHands/OpenHands#20074 (upstream OpenHands/OpenHands#20080).
Priority medium: the deployed Agent Canvas Automate list depends on this filter to page correctly (OpenHands/OpenHands#20074 is built against it), and the short-page/wrong-total behavior was reproduced live against a local Agent Canvas stack; however the current client-side fallback masks part of the impact and there is no direct user report, so this is not high.
Acceptance Criteria
-
GET /v1?in_factory=falsereturns only automations that are in no factory, andtotalcounts only those rows. -
GET /v1?in_factory=truereturns only automations that are in a factory, andtotalcounts only those rows. - A
GET /v1request withoutin_factoryreturns the same rows andtotalas before the change. -
GET /v1?in_factory=false&factory_id=<id of an existing factory>responds HTTP 200 with an empty list andtotal0; the same request within_factory=truereturns that factory's automations. -
in_factorycombines with the other list filters (e.g.tag,created_by,factory_id): returned rows andtotalreflect the combined filter. - With
limit/offsetpaging, every page contains only rows matching the filter andtotalis the same on every page. - Visibility and lifecycle invariants hold for both variants: automations the caller may not see and soft-deleted automations are excluded, and on a fixed dataset
totalwithout the parameter equals thetruetotal plus thefalsetotal. - A non-boolean
in_factoryvalue responds with HTTP 422 and never HTTP 500. - The endpoint still requires
view_automations, andin_factoryappears in the endpoint's OpenAPI schema as an optional boolean. - Automated tests in the repository's test suite cover the omitted,
true,false, andfalse+factory_idcases and pass in CI.
Activity