kaxil opened a new pull request, #76975:
URL: https://github.com/apache/airflow/pull/76975

   Stacked on #76974 (Anthropic and Gemini). Review only the commits after it; 
the two should ship in the same Common AI release.
   
   Moves the OpenAI leg of `@task.llm_batch` onto pydantic-ai's `Model.batch_*` 
methods and deletes the last hand-written adapter (`batch/openai.py`, 459 
lines). This was blocked on the repository's `openai<3` override until #76503: 
`pydantic-ai-slim[openai]` 2.66 needs `openai>=3.31.0`, which the `openai` 
extra now asks for.
   
   ## What changes for an OpenAI task
   
   **Batches run on the Responses API (`/v1/responses`) instead of Chat 
Completions.** pydantic-ai only batches its Responses model. An `openai-chat:` 
model id is built as `openai:` and logged. Two consequences:
   - A Chat Completions key in `request_params` has to be written the Responses 
way, for example `openai_reasoning_effort` instead of `reasoning_effort`. Keys 
pydantic-ai has no typed setting for still go through `extra_body`.
   - A gateway that implements batches only for `/v1/chat/completions` stops 
working. Whether LiteLLM implements them for `/v1/responses` is not verified, 
and the docs say so.
   
   **Settings the Responses model would drop silently now fail before 
submission:** `seed`, `top_k`, `frequency_penalty`, `presence_penalty`, 
`logit_bias` and `stop_sequences` (`OpenAIResponsesModel.unsupported_settings`).
   
   **Orphan recovery by batch metadata is gone.** `batch_create` takes no 
metadata, so a crash between submitting and recording the batch falls through 
to `on_orphaned_intent`, as it already did for Anthropic. Its default, 
`"resubmit"`, submits a new batch.
   
   **An OpenAI batch submitted by the previous version cannot be re-attached.** 
It was created against Chat Completions, and pydantic-ai's Responses decoder 
cannot read its results. The task fails with `LLMBatchStateReadError` naming 
the batch and the fix (let it finish or cancel it, delete the state file, 
retry). Anthropic batches re-attach; only in-flight OpenAI batches at upgrade 
time are affected.
   
   **Input files are not always deleted.** pydantic-ai deletes the uploaded 
input file only in the process that submitted the batch, and only after it has 
seen the job complete. A deferrable task collects in another process, so OpenAI 
keeps the file for its 30-day retention.
   
   ## Known issues
   
   - `completion_window` is ignored (pydantic-ai submits with `24h`); a 
non-default value logs a warning.
   
   ## Evidence
   
   Not run against the live OpenAI API. Unit tests drive real 
`OpenAIResponsesModel` encoding (structured output lands in `text.format`, raw 
keys in the body, managed keys stripped) and pydantic-ai's in-memory batch for 
submit, poll, collect and cancel. The full Common AI suite passes (4777 passed, 
27 skipped); mypy is clean.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to