phanikumv commented on code in PR #77071:
URL: https://github.com/apache/airflow/pull/77071#discussion_r4639580178
##########
providers/common/ai/docs/frameworks/openai_agents.rst:
##########
@@ -558,9 +573,9 @@ Outside a task there is nothing to replay into, and the
agent runs as ``Runner.r
it.
What was recorded is deleted when the agent's run succeeds, so clearing the
task later
-starts over. That happens when ``run_durably_sync`` returns, not when the task
-succeeds: if the task fails after the agent has answered, for example while
writing the
-answer somewhere, the retry runs the whole agent again. Write the answer in a
+starts over. That happens when ``run_durably`` or ``run_durably_sync``
returns, not when
+the task succeeds: if the task fails after the agent has answered, for example
while
+writing the answer somewhere, the retry runs the whole agent again. Write the
answer in a
downstream task, so that a failed write retries on its own. Here
``build_agent()``
stands for building the agent as the task example does:
Review Comment:
Small consistency point: the task example this points to is async now, and
it builds the client inside `async with await OpenAIHook(...).aget_conn()`,
while this snippet is still a sync task with `run_durably_sync`. A sync
`build_agent()` can still get there (with `asyncio.run(...)`, say), but then
the client lifetime is hidden inside it. Could the snippet follow the async
pattern above instead?
```python
@task(retries=2)
async def answer(question: str) -> str:
async with await OpenAIHook(LLM_CONN_ID).aget_conn() as client:
return (await run_durably(build_agent(client), question)).final_output
```
--
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]