From e2331c49673260c2970726337602f75e5d0cfd29 Mon Sep 17 00:00:00 2001 From: Hyu Date: Sun, 2 Aug 2026 01:34:11 +0800 Subject: [PATCH] fix(cloud): restore plugins and pipeline execution (#2379) Co-authored-by: dadachann <185672915+dadachann@users.noreply.github.com> --- pyproject.toml | 2 +- src/langbot/pkg/pipeline/controller.py | 4 +-- .../pipeline/test_controller_tenancy.py | 29 +++++++++++++++++++ uv.lock | 6 ++-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 28890f610..63eb27a84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ dependencies = [ "chromadb>=1.0.0,<2.0.0", "qdrant-client (>=1.15.1,<2.0.0)", "pyseekdb==1.1.0.post3", - "langbot-plugin @ git+https://github.com/langbot-app/langbot-plugin-sdk.git@1d65ed301a6afc52150a998043f73cd6032c8162", + "langbot-plugin @ git+https://github.com/langbot-app/langbot-plugin-sdk.git@101e453e916b39465a6294d6471c9eaae8725d5c", "asyncpg>=0.30.0", "line-bot-sdk>=3.19.0", "matrix-nio>=0.25.2", diff --git a/src/langbot/pkg/pipeline/controller.py b/src/langbot/pkg/pipeline/controller.py index d14288c29..1502ae4de 100644 --- a/src/langbot/pkg/pipeline/controller.py +++ b/src/langbot/pkg/pipeline/controller.py @@ -132,9 +132,7 @@ class Controller: break - if selected_query: # 找到了 - queries.remove(selected_query) - else: # 没找到 说明:没有请求 或者 所有query对应的session都已达到并发上限 + if not selected_query: # 没找到 说明:没有请求 或者 所有query对应的session都已达到并发上限 await self.ap.query_pool.condition.wait() continue diff --git a/tests/unit_tests/pipeline/test_controller_tenancy.py b/tests/unit_tests/pipeline/test_controller_tenancy.py index b99e54bb2..ac999e56b 100644 --- a/tests/unit_tests/pipeline/test_controller_tenancy.py +++ b/tests/unit_tests/pipeline/test_controller_tenancy.py @@ -11,6 +11,7 @@ from sqlalchemy.ext.asyncio import create_async_engine from langbot.pkg.persistence.mgr import PersistenceManager, PersistenceMode from langbot.pkg.persistence.tenant_uow import PersistenceScopeKind from langbot.pkg.pipeline.controller import Controller +from langbot.pkg.pipeline.pool import QueryPool from langbot.pkg.workspace.errors import WorkspaceGenerationMismatchError @@ -143,3 +144,31 @@ async def test_controller_revalidates_generation_before_running_pipeline( runtime_pipeline.run.assert_awaited_once_with(sample_query) query_pool.remove_query.assert_awaited_once_with(sample_query) session._semaphore.release.assert_called_once_with() + + +@pytest.mark.asyncio +async def test_controller_schedules_query_without_removing_it_twice(mock_app, sample_query): + query_pool = QueryPool() + query_pool.queries.append(sample_query) + mock_app.query_pool = query_pool + mock_app.sess_mgr.get_session = AsyncMock(return_value=SimpleNamespace(_semaphore=asyncio.Semaphore(1))) + + scheduler_errors: list[str] = [] + + def stop_on_scheduler_error(message): + scheduler_errors.append(str(message)) + raise asyncio.CancelledError + + def stop_after_scheduling(process_coro, **_kwargs): + process_coro.close() + raise asyncio.CancelledError + + mock_app.logger.error.side_effect = stop_on_scheduler_error + mock_app.task_mgr.create_task.side_effect = stop_after_scheduling + controller = Controller(mock_app) + + with pytest.raises(asyncio.CancelledError): + await controller.consumer() + + assert scheduler_errors == [] + assert query_pool.queries == [] diff --git a/uv.lock b/uv.lock index 5381912a3..c2f7bef76 100644 --- a/uv.lock +++ b/uv.lock @@ -2116,7 +2116,7 @@ requires-dist = [ { name = "ebooklib", specifier = ">=0.18" }, { name = "gewechat-client", specifier = ">=0.1.5" }, { name = "html2text", specifier = ">=2024.2.26" }, - { name = "langbot-plugin", git = "https://github.com/langbot-app/langbot-plugin-sdk.git?rev=1d65ed301a6afc52150a998043f73cd6032c8162" }, + { name = "langbot-plugin", git = "https://github.com/langbot-app/langbot-plugin-sdk.git?rev=101e453e916b39465a6294d6471c9eaae8725d5c" }, { name = "langchain", specifier = ">=1.3.9" }, { name = "langchain-core", specifier = ">=1.3.3" }, { name = "langchain-text-splitters", specifier = ">=1.1.2" }, @@ -2182,8 +2182,8 @@ dev = [ [[package]] name = "langbot-plugin" -version = "0.4.18" -source = { git = "https://github.com/langbot-app/langbot-plugin-sdk.git?rev=1d65ed301a6afc52150a998043f73cd6032c8162#1d65ed301a6afc52150a998043f73cd6032c8162" } +version = "0.5.0" +source = { git = "https://github.com/langbot-app/langbot-plugin-sdk.git?rev=101e453e916b39465a6294d6471c9eaae8725d5c#101e453e916b39465a6294d6471c9eaae8725d5c" } dependencies = [ { name = "aiofiles" }, { name = "aiohttp" },