Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions python/packages/core/agent_framework/_workflows/_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,9 +974,9 @@ async def _on_step_completed() -> None:
span.add_event(OtelAttr.WORKFLOW_STARTED)

with _framework_event_origin():
yield WorkflowEvent.started()
yield WorkflowEvent.started() # noqa: ASYNC119
with _framework_event_origin():
yield WorkflowEvent.status(WorkflowRunState.IN_PROGRESS)
yield WorkflowEvent.status(WorkflowRunState.IN_PROGRESS) # noqa: ASYNC119

# Execute the user function
return_value = await self._execute(ctx, message)
Expand All @@ -999,10 +999,10 @@ async def _on_step_completed() -> None:
for event in ctx._get_events():
if event.type == "request_info":
saw_request = True
yield event
yield event # noqa: ASYNC119
if event.type == "request_info":
with _framework_event_origin():
yield WorkflowEvent.status(WorkflowRunState.IN_PROGRESS_PENDING_REQUESTS)
yield WorkflowEvent.status(WorkflowRunState.IN_PROGRESS_PENDING_REQUESTS) # noqa: ASYNC119

# Save final checkpoint if storage is available
if storage is not None:
Expand All @@ -1012,15 +1012,15 @@ async def _on_step_completed() -> None:
if saw_request:
self._last_pending_request_ids = set(ctx._pending_requests)
with _framework_event_origin():
yield WorkflowEvent.status(WorkflowRunState.IDLE_WITH_PENDING_REQUESTS)
yield WorkflowEvent.status(WorkflowRunState.IDLE_WITH_PENDING_REQUESTS) # noqa: ASYNC119
else:
# Clean completion — drop cross-run replay state.
self._last_message = None
self._last_step_cache = {}
self._last_step_cache_auto_request_info_counts = {}
self._last_pending_request_ids = set()
with _framework_event_origin():
yield WorkflowEvent.status(WorkflowRunState.IDLE)
yield WorkflowEvent.status(WorkflowRunState.IDLE) # noqa: ASYNC119

span.add_event(OtelAttr.WORKFLOW_COMPLETED)

Expand All @@ -1034,30 +1034,30 @@ async def _on_step_completed() -> None:
for event in ctx._get_events():
if event.type == "request_info":
saw_request = True
yield event
yield event # noqa: ASYNC119
if event.type == "request_info":
with _framework_event_origin():
yield WorkflowEvent.status(WorkflowRunState.IN_PROGRESS_PENDING_REQUESTS)
yield WorkflowEvent.status(WorkflowRunState.IN_PROGRESS_PENDING_REQUESTS) # noqa: ASYNC119

# Save checkpoint
if storage is not None:
await self._save_checkpoint(ctx, storage, ckpt_chain[0])

with _framework_event_origin():
yield WorkflowEvent.status(WorkflowRunState.IDLE_WITH_PENDING_REQUESTS)
yield WorkflowEvent.status(WorkflowRunState.IDLE_WITH_PENDING_REQUESTS) # noqa: ASYNC119

span.add_event(OtelAttr.WORKFLOW_COMPLETED)

except Exception as exc:
# Yield any events collected before the failure
for event in ctx._get_events():
yield event
yield event # noqa: ASYNC119

details = WorkflowErrorDetails.from_exception(exc)
with _framework_event_origin():
yield WorkflowEvent.failed(details)
yield WorkflowEvent.failed(details) # noqa: ASYNC119
with _framework_event_origin():
yield WorkflowEvent.status(WorkflowRunState.FAILED)
yield WorkflowEvent.status(WorkflowRunState.FAILED) # noqa: ASYNC119

span.add_event(
name=OtelAttr.WORKFLOW_ERROR,
Expand Down
18 changes: 9 additions & 9 deletions python/packages/core/agent_framework/_workflows/_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,11 @@ async def _run_workflow_with_tracing(
# Emit explicit start/status events to the stream
with _framework_event_origin():
started = WorkflowEvent.started()
yield started # noqa: RUF070
yield started # noqa: RUF070, ASYNC119
self._status = WorkflowRunState.IN_PROGRESS
with _framework_event_origin():
in_progress = WorkflowEvent.status(self._status)
yield in_progress # noqa: RUF070
yield in_progress # noqa: RUF070, ASYNC119

# Per-run reset for fresh-message runs only. We deliberately
# do NOT clear shared workflow state (`_state.clear()`) or the
Expand Down Expand Up @@ -582,41 +582,41 @@ async def _run_workflow_with_tracing(
# Track request events for final status determination
if event.type == "request_info":
saw_request = True
yield event
yield event # noqa: ASYNC119

if event.type == "request_info" and not emitted_in_progress_pending:
emitted_in_progress_pending = True
self._status = WorkflowRunState.IN_PROGRESS_PENDING_REQUESTS
with _framework_event_origin():
pending_status = WorkflowEvent.status(self._status)
yield pending_status # noqa: RUF070
yield pending_status # noqa: RUF070, ASYNC119
# Workflow runs until idle - emit final status based on whether requests are pending
if saw_request:
self._status = WorkflowRunState.IDLE_WITH_PENDING_REQUESTS
with _framework_event_origin():
terminal_status = WorkflowEvent.status(self._status)
yield terminal_status
yield terminal_status # noqa: ASYNC119
else:
self._status = WorkflowRunState.IDLE
with _framework_event_origin():
terminal_status = WorkflowEvent.status(self._status)
yield terminal_status
yield terminal_status # noqa: ASYNC119

span.add_event(OtelAttr.WORKFLOW_COMPLETED)
except Exception as exc:
# Drain any pending events (for example, executor_failed) before yielding failed event
for event in await self._runner.context.drain_events():
yield event
yield event # noqa: ASYNC119

# Surface structured failure details before propagating exception
details = WorkflowErrorDetails.from_exception(exc)
with _framework_event_origin():
failed_event = WorkflowEvent.failed(details)
yield failed_event # noqa: RUF070
yield failed_event # noqa: RUF070, ASYNC119
self._status = WorkflowRunState.FAILED
with _framework_event_origin():
failed_status = WorkflowEvent.status(WorkflowRunState.FAILED)
yield failed_status # noqa: RUF070
yield failed_status # noqa: RUF070, ASYNC119
span.add_event(
name=OtelAttr.WORKFLOW_ERROR,
attributes={
Expand Down
6 changes: 3 additions & 3 deletions python/packages/devui/agent_framework_devui/_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ async def execute_entity(self, entity_id: str, request: AgentFrameworkRequest) -
with capture_traces(response_id=response_id, entity_id=entity_id) as trace_collector:
if entity_info.type == "agent":
async for event in self._execute_agent(entity_obj, request, trace_collector):
yield event
yield event # noqa: ASYNC119
elif entity_info.type == "workflow":
async for event in self._execute_workflow(entity_obj, request, trace_collector):
# Log request_info event (type='request_info') for debugging HIL flow
Expand All @@ -312,13 +312,13 @@ async def execute_entity(self, entity_id: str, request: AgentFrameworkRequest) -
logger.info(f" request_type: {getattr(event, 'request_type', 'N/A')}")
data = getattr(event, "data", None)
logger.info(f" data type: {type(data).__name__ if data else 'None'}")
yield event
yield event # noqa: ASYNC119
else:
raise ValueError(f"Unsupported entity type: {entity_info.type}")

# Yield any remaining trace events after execution completes
for trace_event in trace_collector.get_pending_events():
yield trace_event
yield trace_event # noqa: ASYNC119

except Exception as e:
logger.exception(f"Error executing entity {entity_id}: {e}")
Expand Down
2 changes: 1 addition & 1 deletion python/packages/lab/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ math = [
[dependency-groups]
dev = [
"uv==0.11.17",
"ruff==0.15.15",
"ruff==0.15.17",
"pytest==9.0.3",
"mypy==1.20.0",
"pyright==1.1.408",
Expand Down
6 changes: 3 additions & 3 deletions python/packages/openai/agent_framework_openai/_chat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ async def _stream() -> AsyncIterable[ChatResponseUpdate]:
)
if served_model is not None:
update.model = served_model
yield update
yield update # noqa: ASYNC119
except Exception as ex:
self._handle_request_error(ex)
else:
Expand All @@ -679,7 +679,7 @@ async def _stream() -> AsyncIterable[ChatResponseUpdate]:
# surface the served-model header.
async with client.responses.stream(**run_options) as response:
async for chunk in response:
yield self._parse_chunk_from_openai(
yield self._parse_chunk_from_openai( # noqa: ASYNC119
chunk,
options=validated_options,
function_call_ids=function_call_ids,
Expand All @@ -701,7 +701,7 @@ async def _stream() -> AsyncIterable[ChatResponseUpdate]:
)
if served_model is not None:
update.model = served_model
yield update
yield update # noqa: ASYNC119
except Exception as ex:
self._handle_request_error(ex)

Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
dev = [
"uv==0.11.17",
"flit==3.12.0",
"ruff==0.15.15",
"ruff==0.15.17",
"pytest==9.0.3",
"pytest-asyncio==1.4.0",
"pytest-cov==7.1.0",
Expand Down
Loading
Loading