Skip to content

Commit b2941bd

Browse files
committed
fix: use conversation history to determine eyes reaction in Assistant View DMs
The previous check `not event.get("thread_ts")` never triggered in Assistant View because thread_ts is always present. Instead, check whether a conversation session/history already exists to decide if this is the first message in the thread.
1 parent 743af12 commit b2941bd

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

claude-agent-sdk/listeners/events/message_im.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ async def handle_message_im(
5353
],
5454
)
5555

56-
# Add eyes reaction only to the first message (not threaded replies)
57-
if not event.get("thread_ts"):
56+
# Get session ID for conversation context
57+
existing_session_id = session_store.get_session(channel_id, thread_ts)
58+
59+
# Add eyes reaction only to the first message in a thread
60+
if not existing_session_id:
5861
await client.reactions_add(
5962
channel=channel_id,
6063
timestamp=event["ts"],
6164
name="eyes",
6265
)
6366

64-
# Get session ID for conversation context
65-
existing_session_id = session_store.get_session(channel_id, thread_ts)
66-
6767
# Run the agent
6868
response_text, new_session_id = await run_casey_agent(
6969
text, session_id=existing_session_id

openai-agents-sdk/listeners/events/message_im.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ def handle_message_im(client: WebClient, event: dict, logger: Logger, say: Say):
5252
],
5353
)
5454

55-
# Add eyes reaction only to the first message (not threaded replies)
56-
if not event.get("thread_ts"):
55+
# Get conversation history
56+
history = conversation_store.get_history(channel_id, thread_ts)
57+
58+
# Add eyes reaction only to the first message in a thread
59+
if history is None:
5760
client.reactions_add(
5861
channel=channel_id,
5962
timestamp=event["ts"],
6063
name="eyes",
6164
)
6265

63-
# Get conversation history
64-
history = conversation_store.get_history(channel_id, thread_ts)
65-
6666
# Build input for the agent
6767
if history:
6868
input_items = history + [{"role": "user", "content": text}]

pydantic-ai/listeners/events/message_im.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ def handle_message_im(client: WebClient, event: dict, logger: Logger, say: Say):
5151
],
5252
)
5353

54-
# Add eyes reaction only to the first message (not threaded replies)
55-
if not event.get("thread_ts"):
54+
# Get conversation history
55+
history = conversation_store.get_history(channel_id, thread_ts)
56+
57+
# Add eyes reaction only to the first message in a thread
58+
if history is None:
5659
client.reactions_add(
5760
channel=channel_id,
5861
timestamp=event["ts"],
5962
name="eyes",
6063
)
6164

62-
# Get conversation history
63-
history = conversation_store.get_history(channel_id, thread_ts)
64-
6565
# Run the agent
6666
deps = CaseyDeps(
6767
client=client,

0 commit comments

Comments
 (0)