Improve extract.ai retries, model validation, and OpenAI logs - #1171
Conversation
This drops the shared `deadline` behavior from `extract.ai`, OpenAI transport calls, and AI cache coordination so retries always use the full configured per-attempt timeout. It also renames the default concurrency setting from `max_concurrency` to `default_concurrency`, keeps `threads` as the per-call override, and updates recipe schema/docs to reflect the new timeout/retry semantics. Tests were expanded and adjusted to cover concurrency resolution, transport retry behavior, long retry delays, queued row processing over longer runtimes, and the removal of deadline-specific validation and outcomes.
Changed 'store' setting to true to enable logging at OpenAI.
|
@copilot - when I created this PR, the initial CI failed several extract.ai tests. Please review and fix those. One of the failing tests did not make sense - it was trying to print an error message for every row when it was pointed at an invalid OpenAI model. We use the same model for all rows so there is no need to send repetitive messages. In fact, perhaps we should change the code to check model validity on the first row of the first batch or as a pre-flight check, and if it's invalid fail the recipe at that point without any further submissions. |
Co-authored-by: ebhills <53243273+ebhills@users.noreply.github.com>
Co-authored-by: ebhills <53243273+ebhills@users.noreply.github.com>
Implemented in Recommended disposition: Comment only Next steps
|
Introduces `metadata` support for `extract.ai`, including validation against OpenAI limits, forwarding on both Responses and Chat Completions paths, and automatic diagnostic labels (`recipe_name`, `wrangles_user`) sourced from recipe run context. Recipe context tracking now carries and restores attribution across nested and concurrent runs, with saved/file recipe name detection and XL variable precedence handling. The result-cache identity now includes response storage and effective metadata so attribution/storage variants do not share cached results. Documentation and schema docs were updated for `store` behavior, log visibility, label overrides, and cache implications, and comprehensive offline tests were added for metadata validation, forwarding, context behavior, and cache separation.
Add `jsonschema==4.26.0` to dependency installation steps in `ci.yml` and `publish-tagged.yml` (both full dependency and test-only installs). This keeps GitHub Actions runs consistent and avoids failures from unpinned `jsonschema` version changes.
This fixes
extract.airetries that could exhaust a shared deadline or mishandle failed HTTP responses, stops repeated submissions when OpenAI reports an invalid model, and makes Responses logs available by default with recipe/user attribution.Linked issue
Closes #1170
What changes
timeout; queued rows and retry waits no longer consume a shared budget. Responses now correctly distinguishes transport failures from HTTP error responses and retries eligible failures.extract_ai.default_concurrency, defaulting to 32. An explicitthreadsvalue remains the per-call override.model_not_found, raise once and stop the wrangle instead of submitting the same invalid request for every row. This applies to Responses and Chat Completions, with caching enabled or disabled; the first result can still come from cache.storetotruein both packaged configuration and the missing-setting fallback, enabling inspection in OpenAI Logs > Responses. Per-callstore: falseoverrides the default.metadataobject on both API protocols. Add availablerecipe_nameandwrangles_userlabels automatically. Saved recipes use their title, local files use their basename, and inline callers can supply arecipe_namerun variable. User attribution usesWRANGLES_USER, XL'suser_email, or the configured Wrangles login. Explicit labels override defaults;metadata: {}disables automatic labels. Validation enforces OpenAI's 16-pair, 64-character key, and 512-character value limits.jsonschema==4.26.0in all five CI/release pytest dependency installations, including container and macOS jobs. This fixes the metadata test's missing-import failure during collection without adding a package runtime dependency.How it was verified
Local offline validation: 170 tests passed on Python 3.13.1 for the code committed as
9407a09f. OpenAI requests were mocked; coverage includes retries, invalid-model handling, storage overrides, metadata limits/forwarding, cache separation, and concurrent/nested context cleanup.git diff --checkpassed.Latest GitHub CI at
2ed1ec0cis running: run 34287988288 has passed configuration, schema generation, and the Ubuntu/Python 3.11 pip-install check. The pytest matrix is now in progress; the complete CI result is pending. The prior9407a09frun stopped during test collection becausejsonschemawas missing. Commit2ed1ec0cadds that test dependency; the new CI result is still pending.No live OpenAI, deployed Lambda, or production Excel verification is claimed for the metadata changes. The separate XL companion passed four mocked Jest tests; those are outside this Python PR.
Compatibility and risk
deadlineargument andtotal_deadline_secondsconfiguration entry. Replacement configuration files must renamemax_concurrencytodefault_concurrency; the old key is no longer read. Usetimeout,retries, andthreadsfor call controls.store: falsewhere storage should be disabled, and independently usemetadata: {}to disable automatic labels. Labels are diagnostic attribution, not authenticated audit identities. Only the selected labels are added automatically; metadata attribution adds no authentication or metadata-service lookup.storeoption applies to Responses and is not forwarded as Chat Completions storage. Agents SDK workflow tracing remains separate, with a follow-up issue planned after this work is complete.store: falseplusmetadata: {}. Reverting the PR or restoring the prior package is required to restore the former deadline/concurrency behavior.Ready-for-review checklist
mainand has no merge conflictsSee the pull request workflow.