diff --git a/slack_bolt/app/app.py b/slack_bolt/app/app.py index 566eb82d7..0af27913c 100644 --- a/slack_bolt/app/app.py +++ b/slack_bolt/app/app.py @@ -69,7 +69,7 @@ IgnoringSelfEvents, CustomMiddleware, AttachingFunctionToken, - AttachingAgentKwargs, + AttachingConversationKwargs, ) from slack_bolt.middleware.assistant import Assistant from slack_bolt.middleware.message_listener_matches import MessageListenerMatches @@ -133,7 +133,7 @@ def __init__( listener_executor: Optional[Executor] = None, # for AI Agents & Assistants assistant_thread_context_store: Optional[AssistantThreadContextStore] = None, - attaching_agent_kwargs_enabled: bool = True, + attaching_conversation_kwargs_enabled: bool = True, ): """Bolt App that provides functionalities to register middleware/listeners. @@ -354,7 +354,7 @@ def message_hello(message, say): listener_executor = ThreadPoolExecutor(max_workers=5) self._assistant_thread_context_store = assistant_thread_context_store - self._attaching_agent_kwargs_enabled = attaching_agent_kwargs_enabled + self._attaching_conversation_kwargs_enabled = attaching_conversation_kwargs_enabled self._process_before_response = process_before_response self._listener_runner = ThreadListenerRunner( @@ -844,8 +844,8 @@ def ask_for_introduction(event, say): def __call__(*args, **kwargs): functions = self._to_listener_functions(kwargs) if kwargs else list(args) primary_matcher = builtin_matchers.event(event, base_logger=self._base_logger) - if self._attaching_agent_kwargs_enabled: - middleware.insert(0, AttachingAgentKwargs(self._assistant_thread_context_store)) + if self._attaching_conversation_kwargs_enabled: + middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store)) return self._register_listener(list(functions), primary_matcher, matchers, middleware, True) return __call__ @@ -903,8 +903,8 @@ def __call__(*args, **kwargs): primary_matcher = builtin_matchers.message_event( keyword=keyword, constraints=constraints, base_logger=self._base_logger ) - if self._attaching_agent_kwargs_enabled: - middleware.insert(0, AttachingAgentKwargs(self._assistant_thread_context_store)) + if self._attaching_conversation_kwargs_enabled: + middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store)) middleware.insert(0, MessageListenerMatches(keyword)) return self._register_listener(list(functions), primary_matcher, matchers, middleware, True) diff --git a/slack_bolt/app/async_app.py b/slack_bolt/app/async_app.py index 9cd8c911f..cc94f9e15 100644 --- a/slack_bolt/app/async_app.py +++ b/slack_bolt/app/async_app.py @@ -86,7 +86,7 @@ AsyncIgnoringSelfEvents, AsyncUrlVerification, AsyncAttachingFunctionToken, - AsyncAttachingAgentKwargs, + AsyncAttachingConversationKwargs, ) from slack_bolt.middleware.async_custom_middleware import ( AsyncMiddleware, @@ -142,7 +142,7 @@ def __init__( verification_token: Optional[str] = None, # for AI Agents & Assistants assistant_thread_context_store: Optional[AsyncAssistantThreadContextStore] = None, - attaching_agent_kwargs_enabled: bool = True, + attaching_conversation_kwargs_enabled: bool = True, ): """Bolt App that provides functionalities to register middleware/listeners. @@ -363,7 +363,7 @@ async def message_hello(message, say): # async function self._async_listeners: List[AsyncListener] = [] self._assistant_thread_context_store = assistant_thread_context_store - self._attaching_agent_kwargs_enabled = attaching_agent_kwargs_enabled + self._attaching_conversation_kwargs_enabled = attaching_conversation_kwargs_enabled self._process_before_response = process_before_response self._async_listener_runner = AsyncioListenerRunner( @@ -872,8 +872,8 @@ async def ask_for_introduction(event, say): def __call__(*args, **kwargs): functions = self._to_listener_functions(kwargs) if kwargs else list(args) primary_matcher = builtin_matchers.event(event, True, base_logger=self._base_logger) - if self._attaching_agent_kwargs_enabled: - middleware.insert(0, AsyncAttachingAgentKwargs(self._assistant_thread_context_store)) + if self._attaching_conversation_kwargs_enabled: + middleware.insert(0, AsyncAttachingConversationKwargs(self._assistant_thread_context_store)) return self._register_listener(list(functions), primary_matcher, matchers, middleware, True) return __call__ @@ -934,8 +934,8 @@ def __call__(*args, **kwargs): asyncio=True, base_logger=self._base_logger, ) - if self._attaching_agent_kwargs_enabled: - middleware.insert(0, AsyncAttachingAgentKwargs(self._assistant_thread_context_store)) + if self._attaching_conversation_kwargs_enabled: + middleware.insert(0, AsyncAttachingConversationKwargs(self._assistant_thread_context_store)) middleware.insert(0, AsyncMessageListenerMatches(keyword)) return self._register_listener(list(functions), primary_matcher, matchers, middleware, True) diff --git a/slack_bolt/kwargs_injection/args.py b/slack_bolt/kwargs_injection/args.py index 4cd70176d..f2b4099d6 100644 --- a/slack_bolt/kwargs_injection/args.py +++ b/slack_bolt/kwargs_injection/args.py @@ -104,7 +104,7 @@ def handle_buttons(args): save_thread_context: Optional[SaveThreadContext] """`save_thread_context()` utility function for AI Agents & Assistants""" say_stream: Optional[SayStream] - """`say_stream()` utility function for AI Agents & Assistants""" + """`say_stream()` utility function for conversations, AI Agents & Assistants""" # middleware next: Callable[[], None] """`next()` utility function, which tells the middleware chain that it can continue with the next one""" diff --git a/slack_bolt/middleware/__init__.py b/slack_bolt/middleware/__init__.py index 7b51fb239..c28ffd78d 100644 --- a/slack_bolt/middleware/__init__.py +++ b/slack_bolt/middleware/__init__.py @@ -17,7 +17,7 @@ from .ssl_check import SslCheck from .url_verification import UrlVerification from .attaching_function_token import AttachingFunctionToken -from .attaching_agent_kwargs import AttachingAgentKwargs +from .attaching_conversation_kwargs import AttachingConversationKwargs builtin_middleware_classes = [ SslCheck, @@ -42,6 +42,6 @@ "SslCheck", "UrlVerification", "AttachingFunctionToken", - "AttachingAgentKwargs", + "AttachingConversationKwargs", "builtin_middleware_classes", ] diff --git a/slack_bolt/middleware/assistant/assistant.py b/slack_bolt/middleware/assistant/assistant.py index 9696e826e..ad842f94d 100644 --- a/slack_bolt/middleware/assistant/assistant.py +++ b/slack_bolt/middleware/assistant/assistant.py @@ -7,7 +7,7 @@ from slack_bolt.context.assistant.thread_context_store.store import AssistantThreadContextStore from slack_bolt.listener_matcher.builtins import build_listener_matcher -from slack_bolt.middleware.attaching_agent_kwargs import AttachingAgentKwargs +from slack_bolt.middleware.attaching_conversation_kwargs import AttachingConversationKwargs from slack_bolt.request.request import BoltRequest from slack_bolt.response.response import BoltResponse from slack_bolt.listener_matcher import CustomListenerMatcher @@ -272,7 +272,7 @@ def build_listener( return listener_or_functions elif isinstance(listener_or_functions, list): middleware = middleware if middleware else [] - middleware.insert(0, AttachingAgentKwargs(self.thread_context_store)) + middleware.insert(0, AttachingConversationKwargs(self.thread_context_store)) functions = listener_or_functions ack_function = functions.pop(0) diff --git a/slack_bolt/middleware/assistant/async_assistant.py b/slack_bolt/middleware/assistant/async_assistant.py index d841e2de0..588de8b41 100644 --- a/slack_bolt/middleware/assistant/async_assistant.py +++ b/slack_bolt/middleware/assistant/async_assistant.py @@ -8,7 +8,9 @@ from slack_bolt.listener.asyncio_runner import AsyncioListenerRunner from slack_bolt.listener_matcher.builtins import build_listener_matcher -from slack_bolt.middleware.attaching_agent_kwargs.async_attaching_agent_kwargs import AsyncAttachingAgentKwargs +from slack_bolt.middleware.attaching_conversation_kwargs.async_attaching_conversation_kwargs import ( + AsyncAttachingConversationKwargs, +) from slack_bolt.request.async_request import AsyncBoltRequest from slack_bolt.response import BoltResponse from slack_bolt.error import BoltError @@ -301,7 +303,7 @@ def build_listener( return listener_or_functions elif isinstance(listener_or_functions, list): middleware = middleware if middleware else [] - middleware.insert(0, AsyncAttachingAgentKwargs(self.thread_context_store)) + middleware.insert(0, AsyncAttachingConversationKwargs(self.thread_context_store)) functions = listener_or_functions ack_function = functions.pop(0) diff --git a/slack_bolt/middleware/async_builtins.py b/slack_bolt/middleware/async_builtins.py index 755b55c20..8de07fb88 100644 --- a/slack_bolt/middleware/async_builtins.py +++ b/slack_bolt/middleware/async_builtins.py @@ -10,7 +10,7 @@ AsyncMessageListenerMatches, ) from .attaching_function_token.async_attaching_function_token import AsyncAttachingFunctionToken -from .attaching_agent_kwargs.async_attaching_agent_kwargs import AsyncAttachingAgentKwargs +from .attaching_conversation_kwargs.async_attaching_conversation_kwargs import AsyncAttachingConversationKwargs __all__ = [ "AsyncIgnoringSelfEvents", @@ -19,5 +19,5 @@ "AsyncUrlVerification", "AsyncMessageListenerMatches", "AsyncAttachingFunctionToken", - "AsyncAttachingAgentKwargs", + "AsyncAttachingConversationKwargs", ] diff --git a/slack_bolt/middleware/attaching_agent_kwargs/__init__.py b/slack_bolt/middleware/attaching_agent_kwargs/__init__.py deleted file mode 100644 index 98926fc14..000000000 --- a/slack_bolt/middleware/attaching_agent_kwargs/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .attaching_agent_kwargs import AttachingAgentKwargs - -__all__ = [ - "AttachingAgentKwargs", -] diff --git a/slack_bolt/middleware/attaching_conversation_kwargs/__init__.py b/slack_bolt/middleware/attaching_conversation_kwargs/__init__.py new file mode 100644 index 000000000..ec72e0037 --- /dev/null +++ b/slack_bolt/middleware/attaching_conversation_kwargs/__init__.py @@ -0,0 +1,5 @@ +from .attaching_conversation_kwargs import AttachingConversationKwargs + +__all__ = [ + "AttachingConversationKwargs", +] diff --git a/slack_bolt/middleware/attaching_agent_kwargs/async_attaching_agent_kwargs.py b/slack_bolt/middleware/attaching_conversation_kwargs/async_attaching_conversation_kwargs.py similarity index 97% rename from slack_bolt/middleware/attaching_agent_kwargs/async_attaching_agent_kwargs.py rename to slack_bolt/middleware/attaching_conversation_kwargs/async_attaching_conversation_kwargs.py index 82f1a7671..315ec2a50 100644 --- a/slack_bolt/middleware/attaching_agent_kwargs/async_attaching_agent_kwargs.py +++ b/slack_bolt/middleware/attaching_conversation_kwargs/async_attaching_conversation_kwargs.py @@ -10,7 +10,7 @@ from slack_bolt.response import BoltResponse -class AsyncAttachingAgentKwargs(AsyncMiddleware): +class AsyncAttachingConversationKwargs(AsyncMiddleware): thread_context_store: Optional[AsyncAssistantThreadContextStore] diff --git a/slack_bolt/middleware/attaching_agent_kwargs/attaching_agent_kwargs.py b/slack_bolt/middleware/attaching_conversation_kwargs/attaching_conversation_kwargs.py similarity index 98% rename from slack_bolt/middleware/attaching_agent_kwargs/attaching_agent_kwargs.py rename to slack_bolt/middleware/attaching_conversation_kwargs/attaching_conversation_kwargs.py index 70f41d561..33847fd56 100644 --- a/slack_bolt/middleware/attaching_agent_kwargs/attaching_agent_kwargs.py +++ b/slack_bolt/middleware/attaching_conversation_kwargs/attaching_conversation_kwargs.py @@ -10,7 +10,7 @@ from slack_bolt.response.response import BoltResponse -class AttachingAgentKwargs(Middleware): +class AttachingConversationKwargs(Middleware): thread_context_store: Optional[AssistantThreadContextStore] diff --git a/tests/scenario_tests/test_events_assistant_without_middleware.py b/tests/scenario_tests/test_events_assistant_without_middleware.py index c95f16f99..18072c05e 100644 --- a/tests/scenario_tests/test_events_assistant_without_middleware.py +++ b/tests/scenario_tests/test_events_assistant_without_middleware.py @@ -245,8 +245,8 @@ def handle_message_event( assert response.status == 200 assert listener_called.wait(timeout=0.1) is True - def test_assistant_events_agent_kwargs_disabled(self): - app = App(client=self.web_client, attaching_agent_kwargs_enabled=False) + def test_assistant_events_conversation_kwargs_disabled(self): + app = App(client=self.web_client, attaching_conversation_kwargs_enabled=False) listener_called = Event() diff --git a/tests/scenario_tests_async/test_events_assistant.py b/tests/scenario_tests_async/test_events_assistant.py index 9ccd80c11..edc77ecf3 100644 --- a/tests/scenario_tests_async/test_events_assistant.py +++ b/tests/scenario_tests_async/test_events_assistant.py @@ -216,7 +216,7 @@ async def handle_bot_message(): @pytest.mark.asyncio async def test_assistant_events_kwargs_disabled(self): - app = AsyncApp(client=self.web_client, attaching_agent_kwargs_enabled=False) + app = AsyncApp(client=self.web_client, attaching_conversation_kwargs_enabled=False) listener_called = asyncio.Event() @app.event("assistant_thread_started") diff --git a/tests/scenario_tests_async/test_events_assistant_without_middleware.py b/tests/scenario_tests_async/test_events_assistant_without_middleware.py index 4e82cb2c1..d72b09b04 100644 --- a/tests/scenario_tests_async/test_events_assistant_without_middleware.py +++ b/tests/scenario_tests_async/test_events_assistant_without_middleware.py @@ -268,8 +268,8 @@ async def handle_message_event( assert (await asyncio.wait_for(listener_called.wait(), timeout=0.1)) is True @pytest.mark.asyncio - async def test_assistant_events_agent_kwargs_disabled(self): - app = AsyncApp(client=self.web_client, attaching_agent_kwargs_enabled=False) + async def test_assistant_events_conversation_kwargs_disabled(self): + app = AsyncApp(client=self.web_client, attaching_conversation_kwargs_enabled=False) listener_called = asyncio.Event() diff --git a/tests/slack_bolt/middleware/attaching_agent_kwargs/__init__.py b/tests/slack_bolt/middleware/attaching_conversation_kwargs/__init__.py similarity index 100% rename from tests/slack_bolt/middleware/attaching_agent_kwargs/__init__.py rename to tests/slack_bolt/middleware/attaching_conversation_kwargs/__init__.py diff --git a/tests/slack_bolt/middleware/attaching_agent_kwargs/test_attaching_agent_kwargs.py b/tests/slack_bolt/middleware/attaching_conversation_kwargs/test_attaching_conversation_kwargs.py similarity index 88% rename from tests/slack_bolt/middleware/attaching_agent_kwargs/test_attaching_agent_kwargs.py rename to tests/slack_bolt/middleware/attaching_conversation_kwargs/test_attaching_conversation_kwargs.py index 8e626fd0c..b7785eb50 100644 --- a/tests/slack_bolt/middleware/attaching_agent_kwargs/test_attaching_agent_kwargs.py +++ b/tests/slack_bolt/middleware/attaching_conversation_kwargs/test_attaching_conversation_kwargs.py @@ -1,6 +1,6 @@ from slack_sdk import WebClient -from slack_bolt.middleware.attaching_agent_kwargs import AttachingAgentKwargs +from slack_bolt.middleware.attaching_conversation_kwargs import AttachingConversationKwargs from slack_bolt.request import BoltRequest from slack_bolt.response import BoltResponse from tests.scenario_tests.test_events_assistant import ( @@ -17,9 +17,9 @@ def next(): ASSISTANT_KWARGS = ("say", "set_title", "set_suggested_prompts", "get_thread_context", "save_thread_context") -class TestAttachingAgentKwargs: +class TestAttachingConversationKwargs: def test_assistant_event_attaches_kwargs(self): - middleware = AttachingAgentKwargs() + middleware = AttachingConversationKwargs() req = BoltRequest(body=thread_started_event_body, mode="socket_mode") req.context["client"] = WebClient(token="xoxb-test") @@ -33,7 +33,7 @@ def test_assistant_event_attaches_kwargs(self): assert "set_status" in req.context def test_user_message_event_attaches_kwargs(self): - middleware = AttachingAgentKwargs() + middleware = AttachingConversationKwargs() req = BoltRequest(body=user_message_event_body, mode="socket_mode") req.context["client"] = WebClient(token="xoxb-test") @@ -47,7 +47,7 @@ def test_user_message_event_attaches_kwargs(self): assert "set_status" in req.context def test_non_assistant_event_does_not_attach_kwargs(self): - middleware = AttachingAgentKwargs() + middleware = AttachingConversationKwargs() req = BoltRequest(body=channel_user_message_event_body, mode="socket_mode") req.context["client"] = WebClient(token="xoxb-test") @@ -60,7 +60,7 @@ def test_non_assistant_event_does_not_attach_kwargs(self): assert "set_status" in req.context def test_non_event_does_not_attach_kwargs(self): - middleware = AttachingAgentKwargs() + middleware = AttachingConversationKwargs() req = BoltRequest(body="payload={}", headers={}) resp = middleware.process(req=req, resp=BoltResponse(status=404), next=next) diff --git a/tests/slack_bolt_async/middleware/attaching_agent_kwargs/__init__.py b/tests/slack_bolt_async/middleware/attaching_conversation_kwargs/__init__.py similarity index 100% rename from tests/slack_bolt_async/middleware/attaching_agent_kwargs/__init__.py rename to tests/slack_bolt_async/middleware/attaching_conversation_kwargs/__init__.py diff --git a/tests/slack_bolt_async/middleware/attaching_agent_kwargs/test_async_attaching_agent_kwargs.py b/tests/slack_bolt_async/middleware/attaching_conversation_kwargs/test_async_attaching_conversation_kwargs.py similarity index 87% rename from tests/slack_bolt_async/middleware/attaching_agent_kwargs/test_async_attaching_agent_kwargs.py rename to tests/slack_bolt_async/middleware/attaching_conversation_kwargs/test_async_attaching_conversation_kwargs.py index 61aa0b59e..a00b35cd3 100644 --- a/tests/slack_bolt_async/middleware/attaching_agent_kwargs/test_async_attaching_agent_kwargs.py +++ b/tests/slack_bolt_async/middleware/attaching_conversation_kwargs/test_async_attaching_conversation_kwargs.py @@ -1,7 +1,9 @@ import pytest from slack_sdk.web.async_client import AsyncWebClient -from slack_bolt.middleware.attaching_agent_kwargs.async_attaching_agent_kwargs import AsyncAttachingAgentKwargs +from slack_bolt.middleware.attaching_conversation_kwargs.async_attaching_conversation_kwargs import ( + AsyncAttachingConversationKwargs, +) from slack_bolt.request.async_request import AsyncBoltRequest from slack_bolt.response import BoltResponse from tests.scenario_tests_async.test_events_assistant import ( @@ -18,10 +20,10 @@ async def next(): ASSISTANT_KWARGS = ("say", "set_title", "set_suggested_prompts", "get_thread_context", "save_thread_context") -class TestAsyncAttachingAgentKwargs: +class TestAsyncAttachingConversationKwargs: @pytest.mark.asyncio async def test_assistant_event_attaches_kwargs(self): - middleware = AsyncAttachingAgentKwargs() + middleware = AsyncAttachingConversationKwargs() req = AsyncBoltRequest(body=thread_started_event_body, mode="socket_mode") req.context["client"] = AsyncWebClient(token="xoxb-test") @@ -36,7 +38,7 @@ async def test_assistant_event_attaches_kwargs(self): @pytest.mark.asyncio async def test_user_message_event_attaches_kwargs(self): - middleware = AsyncAttachingAgentKwargs() + middleware = AsyncAttachingConversationKwargs() req = AsyncBoltRequest(body=user_message_event_body, mode="socket_mode") req.context["client"] = AsyncWebClient(token="xoxb-test") @@ -51,7 +53,7 @@ async def test_user_message_event_attaches_kwargs(self): @pytest.mark.asyncio async def test_non_assistant_event_does_not_attach_kwargs(self): - middleware = AsyncAttachingAgentKwargs() + middleware = AsyncAttachingConversationKwargs() req = AsyncBoltRequest(body=channel_user_message_event_body, mode="socket_mode") req.context["client"] = AsyncWebClient(token="xoxb-test") @@ -65,7 +67,7 @@ async def test_non_assistant_event_does_not_attach_kwargs(self): @pytest.mark.asyncio async def test_non_event_does_not_attach_kwargs(self): - middleware = AsyncAttachingAgentKwargs() + middleware = AsyncAttachingConversationKwargs() req = AsyncBoltRequest(body="payload={}", headers={}) resp = await middleware.async_process(req=req, resp=BoltResponse(status=404), next=next)