Skip to content

refactor(api): use sessionmaker in core app generators & pipelines#34771

Merged
asukaminato0721 merged 2 commits intolanggenius:mainfrom
carlos4s:refactor/sessionmaker-core-app-pipelines
Apr 8, 2026
Merged

refactor(api): use sessionmaker in core app generators & pipelines#34771
asukaminato0721 merged 2 commits intolanggenius:mainfrom
carlos4s:refactor/sessionmaker-core-app-pipelines

Conversation

@carlos4s
Copy link
Copy Markdown
Contributor

@carlos4s carlos4s commented Apr 8, 2026

Summary

  • Replace with Session(db.engine) + session.commit() with sessionmaker(bind=db.engine).begin()
    in core app generators and task pipelines
  • Simplify _database_session() context managers: .begin() handles commit/rollback automatically
  • Read-only session blocks (no commit) left unchanged
  • Updated test mocks to match new sessionmaker pattern

Part of #24245

Test plan

  • ruff check passes
  • 801 core app unit tests pass

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. refactor labels Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-08 21:07:58.391120299 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-08 21:07:48.646070306 +0000
@@ -17,9 +17,9 @@
 ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
   --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
 ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
-   --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:323:29
+   --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:321:29
 ERROR Argument `list[Unknown]` is not assignable to parameter `value` with type `SQLCoreOperations[dict[str, Any]] | dict[str, Any]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
-   --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:390:27
+   --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:388:27
 ERROR `defaultdict[str, dict[Unknown, Unknown]]` is not assignable to `defaultdict[ModelType, dict[str, ModelSettings]]` [bad-assignment]
     --> core/entities/provider_configuration.py:1531:79
 ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, int], stream=Literal[False]) [no-matching-overload]
@@ -3072,129 +3072,129 @@
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/core/app/apps/workflow/test_generate_response_converter.py:134:16
 ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:82:18
+  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:83:18
 ERROR Argument `SimpleNamespace` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:83:23
+  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:84:23
 ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:84:14
+  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:85:14
 ERROR Argument `(**kwargs: Unknown) -> None` is not assignable to parameter `draft_var_saver_factory` with type `DraftVariableSaverFactory` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:86:33
+  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:87:33
 ERROR Argument `SimpleNamespace` is not assignable to parameter `publisher` with type `AppGeneratorTTSPublisher | None` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._listen_audio_msg` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:144:57
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:145:57
 ERROR `(err: Unknown) -> Unknown` is not assignable to attribute `error_to_stream_response` with type `(self: BasedGenerateTaskPipeline, e: Exception) -> ErrorStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:159:65
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:160:65
 ERROR `(**kwargs: Unknown) -> Literal['started']` is not assignable to attribute `workflow_start_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_run_id: str, workflow_id: str, reason: WorkflowStartReason) -> WorkflowStartStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:171:83
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:172:83
 ERROR `(**kwargs: Unknown) -> Literal['done']` is not assignable to attribute `workflow_node_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeExceptionEvent | QueueNodeFailedEvent | QueueNodeSucceededEvent, task_id: str) -> NodeFinishStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:187:89
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:188:89
 ERROR `(**kwargs: Unknown) -> Literal['finish']` is not assignable to attribute `workflow_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_id: str, status: WorkflowExecutionStatus, graph_runtime_state: GraphRuntimeState, error: str | None = None, exceptions_count: int = 0) -> WorkflowFinishStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:212:84
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:213:84
 ERROR `(err: Unknown) -> Unknown` is not assignable to attribute `error_to_stream_response` with type `(self: BasedGenerateTaskPipeline, e: Exception) -> ErrorStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:214:65
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:215:65
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_handle_text_chunk_event_publishes_tts._Publisher` is not assignable to parameter `tts_publisher` with type `AppGeneratorTTSPublisher | None` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._handle_text_chunk_event` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:234:68
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:235:68
 ERROR Argument `SimpleNamespace` is not assignable to parameter `queue_message` with type `MessageQueueMessage | WorkflowQueueMessage | None` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._handle_text_chunk_event` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:234:96
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:235:96
 ERROR Object of class `StreamResponse` has no attribute `data` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:237:16
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:238:16
 ERROR `(**kwargs: Unknown) -> Literal['done']` is not assignable to attribute `workflow_node_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeExceptionEvent | QueueNodeFailedEvent | QueueNodeSucceededEvent, task_id: str) -> NodeFinishStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:242:89
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:243:89
 ERROR `(**kwargs: Unknown) -> Literal['finish']` is not assignable to attribute `workflow_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_id: str, status: WorkflowExecutionStatus, graph_runtime_state: GraphRuntimeState, error: str | None = None, exceptions_count: int = 0) -> WorkflowFinishStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:264:84
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:265:84
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_save_workflow_app_log_created_from._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._save_workflow_app_log` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:284:49
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:285:49
 ERROR `(**kwargs: Unknown) -> Literal['iter']` is not assignable to attribute `workflow_iteration_start_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueIterationStartEvent) -> IterationNodeStartStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:291:93
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:292:93
 ERROR `(**kwargs: Unknown) -> Literal['next']` is not assignable to attribute `workflow_iteration_next_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueIterationNextEvent) -> IterationNodeNextStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:292:92
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:293:92
 ERROR `(**kwargs: Unknown) -> Literal['done']` is not assignable to attribute `workflow_iteration_completed_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueIterationCompletedEvent) -> IterationNodeCompletedStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:293:97
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:294:97
 ERROR `(**kwargs: Unknown) -> Literal['loop']` is not assignable to attribute `workflow_loop_start_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueLoopStartEvent) -> LoopNodeStartStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:294:88
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:295:88
 ERROR `(**kwargs: Unknown) -> Literal['loop_next']` is not assignable to attribute `workflow_loop_next_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueLoopNextEvent) -> LoopNodeNextStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:295:87
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:296:87
 ERROR `(**kwargs: Unknown) -> Literal['loop_done']` is not assignable to attribute `workflow_loop_completed_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueLoopCompletedEvent) -> LoopNodeCompletedStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:296:92
-ERROR `(**kwargs: Unknown) -> Literal['filled']` is not assignable to attribute `human_input_form_filled_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueHumanInputFormFilledEvent, task_id: str) -> HumanInputFormFilledResponse` [bad-assignment]
    --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:297:92
+ERROR `(**kwargs: Unknown) -> Literal['filled']` is not assignable to attribute `human_input_form_filled_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueHumanInputFormFilledEvent, task_id: str) -> HumanInputFormFilledResponse` [bad-assignment]
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:298:92
 ERROR `(**kwargs: Unknown) -> Literal['timeout']` is not assignable to attribute `human_input_form_timeout_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueHumanInputFormTimeoutEvent, task_id: str) -> HumanInputFormTimeoutResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:298:93
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:299:93
 ERROR `(**kwargs: Unknown) -> Literal['log']` is not assignable to attribute `handle_agent_log` with type `(self: WorkflowResponseConverter, task_id: str, event: QueueAgentLogEvent) -> AgentLogStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:299:66
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:300:66
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, tts_publisher: AppGeneratorTTSPublisher | None = None, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:391:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:392:45
 ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:447:22
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:448:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:448:27
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:449:27
 ERROR Argument `(**kwargs: Unknown) -> None` is not assignable to parameter `draft_var_saver_factory` with type `DraftVariableSaverFactory` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:451:37
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:452:37
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_wrapper_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:460:53
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:461:53
 ERROR Object of class `tuple` has no attribute `workflow_run_id` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:464:16
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:465:16
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_wrapper_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:467:53
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:468:53
 ERROR Object of class `Generator` has no attribute `workflow_run_id` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:489:16
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:490:16
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, tts_publisher: AppGeneratorTTSPublisher | None = None, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:533:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:534:45
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, tts_publisher: AppGeneratorTTSPublisher | None = None, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:543:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:544:45
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, tts_publisher: AppGeneratorTTSPublisher | None = None, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:580:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:581:45
 ERROR `(**kwargs: Unknown) -> Literal['retry']` is not assignable to attribute `workflow_node_retry_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeRetryEvent, task_id: str) -> NodeRetryStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:670:88
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:671:88
 ERROR `(**kwargs: Unknown) -> Literal['started']` is not assignable to attribute `workflow_node_start_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeStartedEvent, task_id: str) -> NodeStartStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:675:88
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:676:88
 ERROR `(**kwargs: Unknown) -> Literal['failed']` is not assignable to attribute `workflow_node_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeExceptionEvent | QueueNodeFailedEvent | QueueNodeSucceededEvent, task_id: str) -> NodeFinishStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:681:89
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:682:89
 ERROR `(**kwargs: Unknown) -> Literal['finish']` is not assignable to attribute `workflow_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_id: str, status: WorkflowExecutionStatus, graph_runtime_state: GraphRuntimeState, error: str | None = None, exceptions_count: int = 0) -> WorkflowFinishStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:707:84
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:708:84
 ERROR `(**kwargs: Unknown) -> list[str]` is not assignable to attribute `workflow_pause_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueWorkflowPausedEvent, task_id: str, graph_runtime_state: GraphRuntimeState) -> list[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:715:83
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:716:83
 ERROR `(event: QueuePingEvent, **kwargs: Unknown) -> Iterator[PingStreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_ping_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueuePingEvent, **kwargs: Unknown) -> Generator[PingStreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:734:39
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:735:39
 ERROR `(event: QueueStopEvent | QueueWorkflowFailedEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_workflow_failed_and_stop_events` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueStopEvent | QueueWorkflowFailedEvent, *, trace_manager: TraceQueueManager | None = None, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:737:60
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:738:60
 ERROR Argument `SimpleNamespace` is not assignable to parameter `event` with type `AppQueueEvent` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._dispatch_event` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:742:46
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:743:46
 ERROR `() -> Iterator[MessageQueueMessage | WorkflowQueueMessage] | Iterator[Any]` is not assignable to attribute `listen` with type `(self: AppQueueManager) -> Generator[MessageQueueMessage | WorkflowQueueMessage, Unknown]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:750:61
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:751:61
 ERROR `(event: QueueWorkflowStartedEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_workflow_started_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueWorkflowStartedEvent, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:758:51
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:759:51
 ERROR `(event: QueueTextChunkEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_text_chunk_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueTextChunkEvent, *, tts_publisher: AppGeneratorTTSPublisher | None = None, queue_message: MessageQueueMessage | WorkflowQueueMessage | None = None, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:759:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:760:45
 ERROR `(event: AppQueueEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_dispatch_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: AppQueueEvent, *, tts_publisher: AppGeneratorTTSPublisher | None = None, trace_manager: TraceQueueManager | None = None, queue_message: MessageQueueMessage | WorkflowQueueMessage | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:760:36
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:761:36
 ERROR `(event: QueueErrorEvent, **kwargs: Unknown) -> Iterator[ErrorStreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_error_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueErrorEvent, **kwargs: Unknown) -> Generator[ErrorStreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:761:40
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:762:40
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_process_stream_response_main_match_paths_and_cleanup._Publisher` is not assignable to parameter `tts_publisher` with type `AppGeneratorTTSPublisher | None` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._process_stream_response` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:768:74
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:769:74
 ERROR `() -> Iterator[MessageQueueMessage | WorkflowQueueMessage] | Iterator[Any]` is not assignable to attribute `listen` with type `(self: AppQueueManager) -> Generator[MessageQueueMessage | WorkflowQueueMessage, Unknown]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:775:61
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:776:61
 ERROR `(event: QueueStopEvent | QueueWorkflowFailedEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_workflow_failed_and_stop_events` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueStopEvent | QueueWorkflowFailedEvent, *, trace_manager: TraceQueueManager | None = None, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:778:60
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:779:60
 ERROR `() -> Iterator[MessageQueueMessage | WorkflowQueueMessage] | Iterator[Any]` is not assignable to attribute `listen` with type `(self: AppQueueManager) -> Generator[MessageQueueMessage | WorkflowQueueMessage, Unknown]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:781:61
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:782:61
 ERROR `(event: QueueWorkflowPausedEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_workflow_paused_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueWorkflowPausedEvent, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:784:50
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:785:50
 ERROR `() -> Iterator[MessageQueueMessage | WorkflowQueueMessage] | Iterator[Any]` is not assignable to attribute `listen` with type `(self: AppQueueManager) -> Generator[MessageQueueMessage | WorkflowQueueMessage, Unknown]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:787:61
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:788:61
 ERROR `(event: QueueStopEvent | QueueWorkflowFailedEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_workflow_failed_and_stop_events` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueStopEvent | QueueWorkflowFailedEvent, *, trace_manager: TraceQueueManager | None = None, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:790:60
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:791:60
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_save_workflow_app_log_covers_invoke_from_variants._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._save_workflow_app_log` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:803:49
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:804:49
 ERROR Object of class `object` has no attribute `created_from` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:804:16
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:805:16
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_save_workflow_app_log_covers_invoke_from_variants._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._save_workflow_app_log` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:807:49
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:808:49
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_save_workflow_app_log_covers_invoke_from_variants._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._save_workflow_app_log` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:812:49
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:813:49
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_save_workflow_app_log_covers_invoke_from_variants._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._save_workflow_app_log` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:816:49
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:817:49
 ERROR `(**kwargs: Unknown) -> TestWorkflowGenerateTaskPipeline.test_save_output_for_event_writes_draft_variables._Saver` is not assignable to attribute `_draft_var_saver_factory` with type `DraftVariableSaverFactory` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:832:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:833:45
 ERROR `Literal['unknown']` is not assignable to attribute `stopped_by` with type `QueueStopEvent.StopBy` [bad-assignment]
   --> tests/unit_tests/core/app/entities/test_queue_entities.py:11:28
 ERROR Object of class `Mapping` has no attribute `close` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-08 21:43:53.671787786 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-08 21:43:44.807554781 +0000
@@ -17,9 +17,9 @@
 ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
   --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
 ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
-   --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:323:29
+   --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:321:29
 ERROR Argument `list[Unknown]` is not assignable to parameter `value` with type `SQLCoreOperations[dict[str, Any]] | dict[str, Any]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
-   --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:390:27
+   --> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:388:27
 ERROR `defaultdict[str, dict[Unknown, Unknown]]` is not assignable to `defaultdict[ModelType, dict[str, ModelSettings]]` [bad-assignment]
     --> core/entities/provider_configuration.py:1531:79
 ERROR No matching overload found for function `core.model_manager.ModelInstance.invoke_llm` called with arguments: (prompt_messages=list[UserPromptMessage], model_parameters=dict[str, int], stream=Literal[False]) [no-matching-overload]
@@ -3072,129 +3072,129 @@
 ERROR Cannot index into `str` [bad-index]
    --> tests/unit_tests/core/app/apps/workflow/test_generate_response_converter.py:134:16
 ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:82:18
+  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:83:18
 ERROR Argument `SimpleNamespace` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:83:23
+  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:84:23
 ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:84:14
+  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:85:14
 ERROR Argument `(**kwargs: Unknown) -> None` is not assignable to parameter `draft_var_saver_factory` with type `DraftVariableSaverFactory` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:86:33
+  --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:87:33
 ERROR Argument `SimpleNamespace` is not assignable to parameter `publisher` with type `AppGeneratorTTSPublisher | None` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._listen_audio_msg` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:144:57
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:145:57
 ERROR `(err: Unknown) -> Unknown` is not assignable to attribute `error_to_stream_response` with type `(self: BasedGenerateTaskPipeline, e: Exception) -> ErrorStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:159:65
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:160:65
 ERROR `(**kwargs: Unknown) -> Literal['started']` is not assignable to attribute `workflow_start_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_run_id: str, workflow_id: str, reason: WorkflowStartReason) -> WorkflowStartStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:171:83
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:172:83
 ERROR `(**kwargs: Unknown) -> Literal['done']` is not assignable to attribute `workflow_node_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeExceptionEvent | QueueNodeFailedEvent | QueueNodeSucceededEvent, task_id: str) -> NodeFinishStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:187:89
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:188:89
 ERROR `(**kwargs: Unknown) -> Literal['finish']` is not assignable to attribute `workflow_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_id: str, status: WorkflowExecutionStatus, graph_runtime_state: GraphRuntimeState, error: str | None = None, exceptions_count: int = 0) -> WorkflowFinishStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:212:84
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:213:84
 ERROR `(err: Unknown) -> Unknown` is not assignable to attribute `error_to_stream_response` with type `(self: BasedGenerateTaskPipeline, e: Exception) -> ErrorStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:214:65
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:215:65
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_handle_text_chunk_event_publishes_tts._Publisher` is not assignable to parameter `tts_publisher` with type `AppGeneratorTTSPublisher | None` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._handle_text_chunk_event` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:234:68
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:235:68
 ERROR Argument `SimpleNamespace` is not assignable to parameter `queue_message` with type `MessageQueueMessage | WorkflowQueueMessage | None` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._handle_text_chunk_event` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:234:96
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:235:96
 ERROR Object of class `StreamResponse` has no attribute `data` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:237:16
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:238:16
 ERROR `(**kwargs: Unknown) -> Literal['done']` is not assignable to attribute `workflow_node_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeExceptionEvent | QueueNodeFailedEvent | QueueNodeSucceededEvent, task_id: str) -> NodeFinishStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:242:89
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:243:89
 ERROR `(**kwargs: Unknown) -> Literal['finish']` is not assignable to attribute `workflow_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_id: str, status: WorkflowExecutionStatus, graph_runtime_state: GraphRuntimeState, error: str | None = None, exceptions_count: int = 0) -> WorkflowFinishStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:264:84
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:265:84
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_save_workflow_app_log_created_from._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._save_workflow_app_log` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:284:49
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:285:49
 ERROR `(**kwargs: Unknown) -> Literal['iter']` is not assignable to attribute `workflow_iteration_start_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueIterationStartEvent) -> IterationNodeStartStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:291:93
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:292:93
 ERROR `(**kwargs: Unknown) -> Literal['next']` is not assignable to attribute `workflow_iteration_next_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueIterationNextEvent) -> IterationNodeNextStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:292:92
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:293:92
 ERROR `(**kwargs: Unknown) -> Literal['done']` is not assignable to attribute `workflow_iteration_completed_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueIterationCompletedEvent) -> IterationNodeCompletedStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:293:97
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:294:97
 ERROR `(**kwargs: Unknown) -> Literal['loop']` is not assignable to attribute `workflow_loop_start_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueLoopStartEvent) -> LoopNodeStartStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:294:88
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:295:88
 ERROR `(**kwargs: Unknown) -> Literal['loop_next']` is not assignable to attribute `workflow_loop_next_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueLoopNextEvent) -> LoopNodeNextStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:295:87
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:296:87
 ERROR `(**kwargs: Unknown) -> Literal['loop_done']` is not assignable to attribute `workflow_loop_completed_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_execution_id: str, event: QueueLoopCompletedEvent) -> LoopNodeCompletedStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:296:92
-ERROR `(**kwargs: Unknown) -> Literal['filled']` is not assignable to attribute `human_input_form_filled_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueHumanInputFormFilledEvent, task_id: str) -> HumanInputFormFilledResponse` [bad-assignment]
    --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:297:92
+ERROR `(**kwargs: Unknown) -> Literal['filled']` is not assignable to attribute `human_input_form_filled_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueHumanInputFormFilledEvent, task_id: str) -> HumanInputFormFilledResponse` [bad-assignment]
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:298:92
 ERROR `(**kwargs: Unknown) -> Literal['timeout']` is not assignable to attribute `human_input_form_timeout_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueHumanInputFormTimeoutEvent, task_id: str) -> HumanInputFormTimeoutResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:298:93
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:299:93
 ERROR `(**kwargs: Unknown) -> Literal['log']` is not assignable to attribute `handle_agent_log` with type `(self: WorkflowResponseConverter, task_id: str, event: QueueAgentLogEvent) -> AgentLogStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:299:66
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:300:66
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, tts_publisher: AppGeneratorTTSPublisher | None = None, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:391:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:392:45
 ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:447:22
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:448:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:448:27
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:449:27
 ERROR Argument `(**kwargs: Unknown) -> None` is not assignable to parameter `draft_var_saver_factory` with type `DraftVariableSaverFactory` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:451:37
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:452:37
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_wrapper_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:460:53
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:461:53
 ERROR Object of class `tuple` has no attribute `workflow_run_id` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:464:16
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:465:16
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_wrapper_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:467:53
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:468:53
 ERROR Object of class `Generator` has no attribute `workflow_run_id` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:489:16
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:490:16
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, tts_publisher: AppGeneratorTTSPublisher | None = None, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:533:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:534:45
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, tts_publisher: AppGeneratorTTSPublisher | None = None, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:543:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:544:45
 ERROR `(**kwargs: Unknown) -> Iterator[Any]` is not assignable to attribute `_process_stream_response` with type `(self: WorkflowAppGenerateTaskPipeline, tts_publisher: AppGeneratorTTSPublisher | None = None, trace_manager: TraceQueueManager | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:580:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:581:45
 ERROR `(**kwargs: Unknown) -> Literal['retry']` is not assignable to attribute `workflow_node_retry_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeRetryEvent, task_id: str) -> NodeRetryStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:670:88
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:671:88
 ERROR `(**kwargs: Unknown) -> Literal['started']` is not assignable to attribute `workflow_node_start_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeStartedEvent, task_id: str) -> NodeStartStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:675:88
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:676:88
 ERROR `(**kwargs: Unknown) -> Literal['failed']` is not assignable to attribute `workflow_node_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueNodeExceptionEvent | QueueNodeFailedEvent | QueueNodeSucceededEvent, task_id: str) -> NodeFinishStreamResponse | None` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:681:89
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:682:89
 ERROR `(**kwargs: Unknown) -> Literal['finish']` is not assignable to attribute `workflow_finish_to_stream_response` with type `(self: WorkflowResponseConverter, *, task_id: str, workflow_id: str, status: WorkflowExecutionStatus, graph_runtime_state: GraphRuntimeState, error: str | None = None, exceptions_count: int = 0) -> WorkflowFinishStreamResponse` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:707:84
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:708:84
 ERROR `(**kwargs: Unknown) -> list[str]` is not assignable to attribute `workflow_pause_to_stream_response` with type `(self: WorkflowResponseConverter, *, event: QueueWorkflowPausedEvent, task_id: str, graph_runtime_state: GraphRuntimeState) -> list[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:715:83
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:716:83
 ERROR `(event: QueuePingEvent, **kwargs: Unknown) -> Iterator[PingStreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_ping_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueuePingEvent, **kwargs: Unknown) -> Generator[PingStreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:734:39
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:735:39
 ERROR `(event: QueueStopEvent | QueueWorkflowFailedEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_workflow_failed_and_stop_events` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueStopEvent | QueueWorkflowFailedEvent, *, trace_manager: TraceQueueManager | None = None, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:737:60
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:738:60
 ERROR Argument `SimpleNamespace` is not assignable to parameter `event` with type `AppQueueEvent` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._dispatch_event` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:742:46
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:743:46
 ERROR `() -> Iterator[MessageQueueMessage | WorkflowQueueMessage] | Iterator[Any]` is not assignable to attribute `listen` with type `(self: AppQueueManager) -> Generator[MessageQueueMessage | WorkflowQueueMessage, Unknown]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:750:61
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:751:61
 ERROR `(event: QueueWorkflowStartedEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_workflow_started_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueWorkflowStartedEvent, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:758:51
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:759:51
 ERROR `(event: QueueTextChunkEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_text_chunk_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueTextChunkEvent, *, tts_publisher: AppGeneratorTTSPublisher | None = None, queue_message: MessageQueueMessage | WorkflowQueueMessage | None = None, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:759:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:760:45
 ERROR `(event: AppQueueEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_dispatch_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: AppQueueEvent, *, tts_publisher: AppGeneratorTTSPublisher | None = None, trace_manager: TraceQueueManager | None = None, queue_message: MessageQueueMessage | WorkflowQueueMessage | None = None) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:760:36
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:761:36
 ERROR `(event: QueueErrorEvent, **kwargs: Unknown) -> Iterator[ErrorStreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_error_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueErrorEvent, **kwargs: Unknown) -> Generator[ErrorStreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:761:40
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:762:40
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_process_stream_response_main_match_paths_and_cleanup._Publisher` is not assignable to parameter `tts_publisher` with type `AppGeneratorTTSPublisher | None` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._process_stream_response` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:768:74
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:769:74
 ERROR `() -> Iterator[MessageQueueMessage | WorkflowQueueMessage] | Iterator[Any]` is not assignable to attribute `listen` with type `(self: AppQueueManager) -> Generator[MessageQueueMessage | WorkflowQueueMessage, Unknown]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:775:61
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:776:61
 ERROR `(event: QueueStopEvent | QueueWorkflowFailedEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_workflow_failed_and_stop_events` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueStopEvent | QueueWorkflowFailedEvent, *, trace_manager: TraceQueueManager | None = None, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:778:60
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:779:60
 ERROR `() -> Iterator[MessageQueueMessage | WorkflowQueueMessage] | Iterator[Any]` is not assignable to attribute `listen` with type `(self: AppQueueManager) -> Generator[MessageQueueMessage | WorkflowQueueMessage, Unknown]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:781:61
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:782:61
 ERROR `(event: QueueWorkflowPausedEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_workflow_paused_event` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueWorkflowPausedEvent, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:784:50
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:785:50
 ERROR `() -> Iterator[MessageQueueMessage | WorkflowQueueMessage] | Iterator[Any]` is not assignable to attribute `listen` with type `(self: AppQueueManager) -> Generator[MessageQueueMessage | WorkflowQueueMessage, Unknown]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:787:61
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:788:61
 ERROR `(event: QueueStopEvent | QueueWorkflowFailedEvent, **kwargs: Unknown) -> Iterator[StreamResponse] | Iterator[Any]` is not assignable to attribute `_handle_workflow_failed_and_stop_events` with type `(self: WorkflowAppGenerateTaskPipeline, event: QueueStopEvent | QueueWorkflowFailedEvent, *, trace_manager: TraceQueueManager | None = None, **kwargs: Unknown) -> Generator[StreamResponse]` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:790:60
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:791:60
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_save_workflow_app_log_covers_invoke_from_variants._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._save_workflow_app_log` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:803:49
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:804:49
 ERROR Object of class `object` has no attribute `created_from` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:804:16
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:805:16
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_save_workflow_app_log_covers_invoke_from_variants._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._save_workflow_app_log` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:807:49
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:808:49
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_save_workflow_app_log_covers_invoke_from_variants._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._save_workflow_app_log` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:812:49
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:813:49
 ERROR Argument `TestWorkflowGenerateTaskPipeline.test_save_workflow_app_log_covers_invoke_from_variants._Session` is not assignable to parameter `session` with type `Session` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline._save_workflow_app_log` [bad-argument-type]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:816:49
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:817:49
 ERROR `(**kwargs: Unknown) -> TestWorkflowGenerateTaskPipeline.test_save_output_for_event_writes_draft_variables._Saver` is not assignable to attribute `_draft_var_saver_factory` with type `DraftVariableSaverFactory` [bad-assignment]
-   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:832:45
+   --> tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py:833:45
 ERROR `Literal['unknown']` is not assignable to attribute `stopped_by` with type `QueueStopEvent.StopBy` [bad-assignment]
   --> tests/unit_tests/core/app/entities/test_queue_entities.py:11:28
 ERROR Object of class `Mapping` has no attribute `close` [missing-attribute]

@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 8, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 8, 2026
@asukaminato0721 asukaminato0721 requested a review from Copilot April 8, 2026 23:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors several core app generators/pipelines to use SQLAlchemy’s sessionmaker(...).begin() transactional context manager instead of manually managing Session(...) plus explicit commit()/rollback(), and updates unit tests/mocks accordingly.

Changes:

  • Replaced with Session(db.engine) ... session.commit() patterns with with sessionmaker(bind=db.engine).begin() as session: in task pipelines and quota deduction logic.
  • Simplified _database_session() context managers by relying on .begin() for automatic commit/rollback handling.
  • Updated unit test mocks/assertions to reflect the new sessionmaker().begin() usage.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py Uses sessionmaker(...).begin() for DB writes during stream processing (error handling, message saving).
api/core/app/llm/quota.py Uses sessionmaker(...).begin() for quota update transaction, removing explicit commit.
api/core/app/apps/workflow/generate_task_pipeline.py Refactors _database_session() to sessionmaker(...).begin() with expire_on_commit=False.
api/core/app/apps/advanced_chat/generate_task_pipeline.py Refactors _database_session() similarly to use sessionmaker(...).begin() with expire_on_commit=False.
api/core/app/apps/advanced_chat/app_runner.py Switches conversation-variable initialization to sessionmaker(...).begin() and removes explicit commit.
api/tests/unit_tests/core/app/apps/workflow/test_generate_task_pipeline_core.py Updates rollback-on-error test to patch sessionmaker/begin() and assert exception propagation through context exit.
api/tests/unit_tests/core/app/apps/advanced_chat/test_app_runner_input_moderation.py Updates patching to include sessionmaker().begin() context used by conversation-variable initialization.
api/tests/unit_tests/core/app/apps/advanced_chat/test_app_runner_conversation_variables.py Updates mocks/assertions to reflect sessionmaker().begin() (no explicit commit assertion).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Merged via the queue into langgenius:main with commit 02a9f0a Apr 8, 2026
31 checks passed
@carlos4s carlos4s deleted the refactor/sessionmaker-core-app-pipelines branch April 9, 2026 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants