fix(agent-server): size bash event pages by returned events, not files read - #4396
fix(agent-server): size bash event pages by returned events, not files read#4396Shailendra005 wants to merge 2 commits into
Conversation
|
Minor consistency note (non-blocking for me): the two new tests use |
|
@neubig good call — converted in the latest commit. Both tests are now Their pyright hook then flagged a second thing worth keeping: |
HUMAN:
Took this one because a cursor that keeps pointing at nothing is worse than an error — the client can't tell the difference between "slow" and "broken".
AGENT:
Why
search_bash_eventspicks up tolimitfiles, then appliesorder__gtwhile loading them. The page boundary is therefore measured before the filter runs, so a page can come back short — or completely empty — whilenext_page_idis still set. A client following the cursor walks a run of under-full pages, and in the all-filtered case never makes progress.order__gtis how incremental command-output polling works ("give me output after chunk N"), so this is a live path rather than a corner case. Reported in #4388.Summary
_load_event_from_filereturningNone) no longer consumes a page slot either — previously it silently shrank the page the same way.next_page_idsemantics are unchanged: it points at the first file not consumed by this page.Issue Number
Closes #4388
How to Test
Two tests in
tests/agent_server/test_bash_service.py:test_order_filter_does_not_undersize_pages— 15 outputs,order__gt=9,limit=5. Expects a full page of orders 10–14.test_order_filter_never_returns_an_empty_page_with_a_cursor— every event filtered out. Expects no items and no cursor.Both fail on
mainwith the reported behaviour:The tests give each event an increasing timestamp, since files sort by name and same-timestamp events would otherwise come back in a nondeterministic order.
Full suite and checks:
Note
A full page still carries a
next_page_ideven when every remaining file would be filtered out — the service cannot know that without reading them. The following request then returns an empty page with no cursor, so the client terminates after one extra round trip rather than looping. Making that last hop disappear would mean reading ahead past the page boundary, which seemed a worse trade than one predictable extra call; happy to revisit if you would rather pay that cost.