<span id="运行历史查询规则"></span>

# Run history query rules

Both lists require the path workspace to match X-Workspace-ID. IDs cannot be empty, have surrounding whitespace, exceed 128 bytes, or contain slashes/backslashes. A task path ID is not a run ID.

| Condition | Verified implementation |
| --- | --- |
| Task scope | Supplied by automation_task_id in the task-history path. The workspace list does not read a same-named query parameter. |
| State | queued, running, input_required, pending_approval, succeeded, failed, canceled, or expired. Nonempty invalid values return 400. |
| Time | created_at>=created_from and created_at<created_to. Use RFC3339 and URL-encode to preserve timezone offsets. |
| Range order | No separate from<to check currently. Reversed/equal ranges do not establish business validity merely because parameter validation passed. |
| Page size | For ordinary inputs, omitted/0/negative values default to 50; values above 200 are capped at 200. |
| Offset | Omitted defaults to 0 and negative becomes 0; not a cursor. |
| Sorting | created_at descending, id ascending. Run events are chronological instead; keep these orders distinct. |
| No match | items=[], total=0. Task paths do not first verify parent task existence and may return 200 without matches. |

The handler currently ignores integer-conversion errors. Ordinary noninteger strings may become zero, but overflow depends on Go integer conversion results. Do not promise that every invalid number defaults or returns 400. Use integers within range. Unknown query parameters do not create filters.

Continue with effective offset+limit and stop at an empty page or total. A page shorter than limit alone does not establish completion. During concurrent writes/state changes, deduplicate by run ID and check the business time window again. This is not a fixed snapshot query.
