Repository navigation
fix: save online responses that parse_func rejects or filters out - #748
TanishGudise wants to merge 1 commit into
Conversation
append_generic_response returned before writing the response when parse_func raised or returned no rows. The response was paid for but never saved, so a resumed run sent the request again, and a fixed parse_func couldn't rebuild the dataset from the cache. With the default require_all_responses=True, a parse_func that filters rows by returning [] also made every run fail with "Some requests do not have responses". Write the response first and skip only the parsed-row count and viewer stream when there are no rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Strix Security ReviewNo security issues found. Review summaryReviewed the production-code change in Updated for Reviewed by Strix |
EntelligenceAI PR SummaryUpdated flowchart TD
classDef newBehavior fill:#dcfce7,stroke:#16a34a,color:#14532d;
A["API response received"] --> B["parse_func processes response"]
B --> C["Persist raw and parsed response"]
C --> D["Resume skips completed request"]
C --> E["Dataset rebuild uses cached response"]
B --> F["No parsed rows or parse error"]
F --> C
class B,C,D,E,F newBehavior;
Review Scorecard
Safe to merge with a low blast radius; code quality rated Excellent (5/5): the review found nothing to flag. Key Findings:
Evaluated against
|
WalkthroughThis update strengthens online response caching and resume behavior by persisting every processed response, including parse failures and empty results. It also expands unit coverage to verify skipped re-requests, completion tracking, dataset reconstruction from cached responses, and exclusion of filtered rows. ChangesFiles
Updated Files
Expanded unit tests with lightweight processor fixtures and response helpers covering caching, resume behavior, parse exceptions, empty parse results, completion tracking, dataset rebuilding after parser fixes, and filtering without run failure. |
Closes #744
append_generic_responsereturned before writing a response whenparse_funcraised or returned no rows. The response was paid for but never saved, so a resumed run sent the request again, and a fixedparse_funccouldn't rebuild the dataset from the cache. With the defaultrequire_all_responses=True, aparse_functhat drops rows by returning[]also made every run fail with "Some requests do not have responses".This writes the response first, then returns early only before the parsed-row count and the viewer stream.
create_dataset_filesalready re-runsparse_funcon every saved response without errors, so:parse_funcraised on is counted as a failed request when the dataset is built, and afterparse_funcis fixed the dataset is rebuilt from the saved response without a new request;[]is skipped when the dataset is built and no longer counts as missing.Responses that don't match
response_formatdon't reach this write:handle_single_request_with_retriesvalidates the format first and retries. Batch mode isn't changed here: its early return (base_batch_request_processor.pyL606-L610) also coversresponse_formatmismatches, and it already saves[]results.Visible changes (all only when
parse_funcraises or returns[]):parse_funcraises on some rows andrequire_all_responses=True, the error is now "Some requests failed and require_all_responses is True" instead of "Some requests do not have responses". Its error sample is empty, becausecreate_dataset_filesonly samples API errors, as it already does when a changedparse_funcfails on cached responses.parse_funcraises on every row, the error is "All requests failed" instead of "No responses files found". When it returns[]for every row,datasetsraisesSchemaInferenceError("at least one example") instead. In both cases a re-run now sends 0 requests instead of all of them again.parse_funccan't handle aNoneresponse, as it already was without aparse_func. Withrequire_all_responses=Truethe error then reads "Some requests failed" with a sample of the API errors. On resume these entries are removed and retried, so resume behaviour is unchanged.parse_funcraises, its warning is logged twice: once when the response is saved and once when the dataset is built.Tests (
tests/unittests/test_base_online_request_processor.py)parse_funcraises on, or filters out, is incompleted_request_idson resume (fails on main:{0, 2}instead of{0, 1, 2}).parse_funcis fixed, the dataset is rebuilt from the saved responses with every row (fails on main).[]don't fail the run under the defaultrequire_all_responses=True(fails on main).Each part of the fix removed on its own makes a test fail: still dropping
[]results, still droppingparse_funcerrors, and dropping the early return after the write.Manual check: end to end against a local OpenAI-compatible stub, 10 rows,
parse_funcraising on 2: main saved 8 responses and the re-run with the fixedparse_funcsent 2 requests; with this change 10 are saved and the re-run sends 0. Filtering 2 rows with default settings: main failed all 3 runs (10, 2 and 2 requests sent); with this change all 3 runs succeed with 8 rows (10, 0 and 0 requests).Without network access, the full test suite has no new failures compared with main: the offline failures are tests that need the network, plus
test_simple_code_execution_local, which also fails locally on main.CI note: CI on main is currently red for reasons unrelated to this PR:
test_basic_reasoningandtest_batch_reasoningfail because litellm 1.83.7 doesn't mapclaude-3-7-sonnet-20250219, and total coverage is 78%, under--cov-fail-under=80(run 37956501158 on 31abdb7). Once CI runs here (first-time contributor runs wait for approval), those failures will show on this PR too until main is fixed.🤖 Generated with Claude Code