Skip to content
Merged
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
6 changes: 4 additions & 2 deletions claude-agent-sdk/listeners/events/app_mentioned.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
from logging import Logger

from slack_bolt.agent.async_agent import AsyncBoltAgent
from slack_bolt.context.async_context import AsyncBoltContext
from slack_bolt.context.say.async_say import AsyncSay
from slack_sdk.web.async_client import AsyncWebClient
Expand All @@ -24,6 +25,7 @@

async def handle_app_mentioned(
client: AsyncWebClient,
agent: AsyncBoltAgent,
context: AsyncBoltContext,
event: dict,
logger: Logger,
Expand Down Expand Up @@ -78,9 +80,9 @@ async def handle_app_mentioned(
)

# Stream response in thread with feedback buttons
streamer = await client.chat_stream(
streamer = await agent.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_team_id=team_id, # chat_stream helper cannot infer event["team"] from client
recipient_user_id=user_id,
thread_ts=thread_ts,
)
Expand Down
11 changes: 3 additions & 8 deletions claude-agent-sdk/listeners/events/message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import random
from logging import Logger

from slack_bolt.agent.async_agent import AsyncBoltAgent
from slack_bolt.context.async_context import AsyncBoltContext
from slack_bolt.context.say.async_say import AsyncSay
from slack_sdk.web.async_client import AsyncWebClient
Expand All @@ -23,6 +24,7 @@

async def handle_message(
client: AsyncWebClient,
agent: AsyncBoltAgent,
context: AsyncBoltContext,
event: dict,
logger: Logger,
Expand All @@ -39,10 +41,8 @@ async def handle_message(

try:
channel_id = context.channel_id
team_id = context.team_id
text = event.get("text", "")
thread_ts = event.get("thread_ts") or event["ts"]
user_id = context.user_id

# Get session ID for conversation context
existing_session_id = session_store.get_session(channel_id, thread_ts)
Expand Down Expand Up @@ -75,12 +75,7 @@ async def handle_message(
)

# Stream response in thread with feedback buttons
streamer = await client.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_user_id=user_id,
thread_ts=thread_ts,
)
streamer = await agent.chat_stream()
await streamer.append(markdown_text=response_text)
feedback_blocks = create_feedback_block()
await streamer.stop(blocks=feedback_blocks)
Expand Down
4 changes: 3 additions & 1 deletion claude-agent-sdk/listeners/views/issue_modal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from logging import Logger

from slack_bolt import Ack
from slack_bolt.agent.async_agent import AsyncBoltAgent
from slack_bolt.context.async_context import AsyncBoltContext
from slack_sdk.web.async_client import AsyncWebClient

Expand All @@ -11,6 +12,7 @@

async def handle_issue_submission(
ack: Ack,
agent: AsyncBoltAgent,
body: dict,
client: AsyncWebClient,
context: AsyncBoltContext,
Expand Down Expand Up @@ -65,7 +67,7 @@ async def handle_issue_submission(
response_text, new_session_id = await run_casey_agent(user_message)

# Stream the response in thread with feedback buttons
streamer = await client.chat_stream(
streamer = await agent.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_user_id=user_id,
Expand Down
13 changes: 9 additions & 4 deletions openai-agents-sdk/listeners/events/app_mentioned.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from logging import Logger

from agents import Runner
from slack_bolt import BoltContext, Say
from slack_bolt import BoltAgent, BoltContext, Say
from slack_sdk import WebClient

from agent import CaseyDeps, casey_agent
Expand All @@ -23,7 +23,12 @@


def handle_app_mentioned(
client: WebClient, context: BoltContext, event: dict, logger: Logger, say: Say
agent: BoltAgent,
client: WebClient,
context: BoltContext,
event: dict,
logger: Logger,
say: Say,
):
"""Handle @Casey mentions in channels."""
try:
Expand Down Expand Up @@ -83,9 +88,9 @@ def handle_app_mentioned(
result = Runner.run_sync(casey_agent, input=input_items, context=deps)

# Stream response in thread with feedback buttons
streamer = client.chat_stream(
streamer = agent.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_team_id=team_id, # chat_stream helper cannot infer event["team"] from client
recipient_user_id=user_id,
thread_ts=thread_ts,
)
Expand Down
17 changes: 8 additions & 9 deletions openai-agents-sdk/listeners/events/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from logging import Logger

from agents import Runner
from slack_bolt import BoltContext, Say
from slack_bolt import BoltAgent, BoltContext, Say
from slack_sdk import WebClient

from agent import CaseyDeps, casey_agent
Expand All @@ -22,7 +22,12 @@


def handle_message(
client: WebClient, context: BoltContext, event: dict, logger: Logger, say: Say
agent: BoltAgent,
client: WebClient,
context: BoltContext,
event: dict,
logger: Logger,
say: Say,
):
"""Handle direct messages sent to Casey."""
# Skip bot messages and message subtypes (edits, deletes, etc.)
Expand All @@ -35,7 +40,6 @@ def handle_message(

try:
channel_id = context.channel_id
team_id = context.team_id
text = event.get("text", "")
thread_ts = event.get("thread_ts") or event["ts"]
user_id = context.user_id
Expand Down Expand Up @@ -81,12 +85,7 @@ def handle_message(
result = Runner.run_sync(casey_agent, input=input_items, context=deps)

# Stream response in thread with feedback buttons
streamer = client.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_user_id=user_id,
thread_ts=thread_ts,
)
streamer = agent.chat_stream()
streamer.append(markdown_text=result.final_output)
feedback_blocks = create_feedback_block()
streamer.stop(blocks=feedback_blocks)
Expand Down
11 changes: 8 additions & 3 deletions openai-agents-sdk/listeners/views/issue_modal.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from logging import Logger

from agents import Runner
from slack_bolt import Ack, BoltContext
from slack_bolt import Ack, BoltAgent, BoltContext
from slack_sdk import WebClient

from agent import CaseyDeps, casey_agent
Expand All @@ -10,7 +10,12 @@


def handle_issue_submission(
ack: Ack, body: dict, client: WebClient, context: BoltContext, logger: Logger
ack: Ack,
agent: BoltAgent,
body: dict,
client: WebClient,
context: BoltContext,
logger: Logger,
):
"""Handle modal submission: open DM, post issue, and run Casey agent."""
ack()
Expand Down Expand Up @@ -67,7 +72,7 @@ def handle_issue_submission(
result = Runner.run_sync(casey_agent, input=user_message, context=deps)

# Stream the response in thread with feedback buttons
streamer = client.chat_stream(
streamer = agent.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_user_id=user_id,
Expand Down
13 changes: 9 additions & 4 deletions pydantic-ai/listeners/events/app_mentioned.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
from logging import Logger

from slack_bolt import BoltContext, Say
from slack_bolt import BoltAgent, BoltContext, Say
from slack_sdk import WebClient

from agent import DEFAULT_MODEL, CaseyDeps, casey_agent
Expand All @@ -22,7 +22,12 @@


def handle_app_mentioned(
client: WebClient, context: BoltContext, event: dict, logger: Logger, say: Say
agent: BoltAgent,
client: WebClient,
context: BoltContext,
event: dict,
logger: Logger,
say: Say,
):
"""Handle @Casey mentions in channels."""
try:
Expand Down Expand Up @@ -82,9 +87,9 @@ def handle_app_mentioned(
)

# Stream response in thread with feedback buttons
streamer = client.chat_stream(
streamer = agent.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_team_id=team_id, # chat_stream helper cannot infer event["team"] from client
recipient_user_id=user_id,
thread_ts=thread_ts,
)
Expand Down
17 changes: 8 additions & 9 deletions pydantic-ai/listeners/events/message.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random
from logging import Logger

from slack_bolt import BoltContext, Say
from slack_bolt import BoltAgent, BoltContext, Say
from slack_sdk import WebClient

from agent import DEFAULT_MODEL, CaseyDeps, casey_agent
Expand All @@ -21,7 +21,12 @@


def handle_message(
client: WebClient, context: BoltContext, event: dict, logger: Logger, say: Say
agent: BoltAgent,
client: WebClient,
context: BoltContext,
event: dict,
logger: Logger,
say: Say,
):
"""Handle direct messages sent to Casey."""
# Skip bot messages and message subtypes (edits, deletes, etc.)
Expand All @@ -34,7 +39,6 @@ def handle_message(

try:
channel_id = context.channel_id
team_id = context.team_id
text = event.get("text", "")
thread_ts = event.get("thread_ts") or event["ts"]
user_id = context.user_id
Expand Down Expand Up @@ -79,12 +83,7 @@ def handle_message(
)

# Stream response in thread with feedback buttons
streamer = client.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_user_id=user_id,
thread_ts=thread_ts,
)
streamer = agent.chat_stream()
streamer.append(markdown_text=result.output)
feedback_blocks = create_feedback_block()
streamer.stop(blocks=feedback_blocks)
Expand Down
11 changes: 8 additions & 3 deletions pydantic-ai/listeners/views/issue_modal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from logging import Logger

from slack_bolt import Ack, BoltContext
from slack_bolt import Ack, BoltAgent, BoltContext
from slack_sdk import WebClient

from agent import DEFAULT_MODEL, CaseyDeps, casey_agent
Expand All @@ -9,7 +9,12 @@


def handle_issue_submission(
ack: Ack, body: dict, client: WebClient, context: BoltContext, logger: Logger
ack: Ack,
agent: BoltAgent,
body: dict,
client: WebClient,
context: BoltContext,
logger: Logger,
):
"""Handle modal submission: open DM, post issue, and run Casey agent."""
ack()
Expand Down Expand Up @@ -66,7 +71,7 @@ def handle_issue_submission(
result = casey_agent.run_sync(user_message, model=DEFAULT_MODEL, deps=deps)

# Stream the response in thread with feedback buttons
streamer = client.chat_stream(
streamer = agent.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_user_id=user_id,
Expand Down