Skip to content

Commit 0f92639

Browse files
committed
feat(openai): sync eyes reaction and feedback blocks with pydantic-ai
1 parent cec90c6 commit 0f92639

8 files changed

Lines changed: 39 additions & 38 deletions

File tree

.claude/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ Each sub-package has a `register(app)` function called from `listeners/__init__.
7070
| Result output | `result.output` | `result.final_output` |
7171
| Result messages | `result.all_messages()` | `result.to_input_list()` |
7272
| History type | `list[ModelMessage]` (framework-native) | `list` (generic, manually constructed) |
73-
| Feedback blocks | Native `FeedbackButtonsElement` | Custom `ButtonElement` pair |
73+
| Feedback blocks | Native `FeedbackButtonsElement` | Native `FeedbackButtonsElement` |

openai-agents-sdk/.claude/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ See the root `../.claude/CLAUDE.md` for monorepo-wide architecture, commands, an
1010

1111
**Conversation history** is stored as a generic `list` and must be manually combined with new user input before passing to `Runner.run_sync()`: `input_items = history + [{"role": "user", "content": text}]`. After execution, `result.to_input_list()` is stored back.
1212

13-
**Feedback blocks** use custom `ButtonElement` pairs inside an `ActionsBlock`, with separate `feedback_good` and `feedback_bad` action IDs. The `create_feedback_block(thread_ts)` function takes a timestamp to generate a unique `block_id`.
13+
**Feedback blocks** use the native `FeedbackButtonsElement` from `slack_sdk.models.blocks`. A single `feedback` action ID is registered.
1414

1515
The `message_im` handler adds the `:eyes:` reaction on every message (including thread replies).

openai-agents-sdk/listeners/actions/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88

99
def register(app: App):
1010
app.action(re.compile(r"^category_"))(handle_category_button)
11-
app.action("feedback_good")(handle_feedback)
12-
app.action("feedback_bad")(handle_feedback)
11+
app.action("feedback")(handle_feedback)

openai-agents-sdk/listeners/actions/feedback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def handle_feedback(ack: Ack, body: dict, client: WebClient, logger: Logger):
1414
message_ts = body["message"]["ts"]
1515
feedback_value = body["actions"][0]["value"]
1616

17-
if feedback_value == "good":
17+
if feedback_value == "good-feedback":
1818
client.chat_postEphemeral(
1919
channel=channel_id,
2020
user=user_id,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def handle_app_mentioned(client: WebClient, event: dict, logger: Logger, say: Sa
6666
result = Runner.run_sync(casey_agent, input=input_items, context=deps)
6767

6868
# Post response in thread with feedback buttons
69-
feedback_blocks = create_feedback_block(thread_ts)
69+
feedback_blocks = create_feedback_block()
7070
response_blocks = [
7171
{
7272
"type": "section",

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ def handle_message_im(client: WebClient, event: dict, logger: Logger, say: Say):
3737
thread_ts = event.get("thread_ts") or event["ts"]
3838
user_id = event["user"]
3939

40-
# Add eyes reaction
41-
client.reactions_add(
42-
channel=channel_id,
43-
timestamp=event["ts"],
44-
name="eyes",
45-
)
40+
# Add eyes reaction only to the first message (not threaded replies)
41+
if not event.get("thread_ts"):
42+
client.reactions_add(
43+
channel=channel_id,
44+
timestamp=event["ts"],
45+
name="eyes",
46+
)
4647

4748
# Get conversation history
4849
history = conversation_store.get_history(channel_id, thread_ts)
@@ -63,7 +64,7 @@ def handle_message_im(client: WebClient, event: dict, logger: Logger, say: Say):
6364
result = Runner.run_sync(casey_agent, input=input_items, context=deps)
6465

6566
# Post response in thread with feedback buttons
66-
feedback_blocks = create_feedback_block(thread_ts)
67+
feedback_blocks = create_feedback_block()
6768
response_blocks = [
6869
{
6970
"type": "section",
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
from slack_sdk.models.blocks import (
2-
ActionsBlock,
3-
ButtonElement,
2+
Block,
3+
ContextActionsBlock,
4+
FeedbackButtonObject,
5+
FeedbackButtonsElement,
46
)
57

68

7-
def create_feedback_block(message_ts: str = "") -> list[dict]:
8-
"""Create feedback block with thumbs up/down buttons.
9-
10-
Args:
11-
message_ts: Optional timestamp to identify which message feedback is for.
12-
"""
13-
block = ActionsBlock(
14-
block_id=f"feedback_{message_ts}" if message_ts else "feedback",
15-
elements=[
16-
ButtonElement(
17-
text=":thumbsup:",
18-
action_id="feedback_good",
19-
value="good",
20-
),
21-
ButtonElement(
22-
text=":thumbsdown:",
23-
action_id="feedback_bad",
24-
value="bad",
25-
),
26-
],
27-
)
28-
return [block.to_dict()]
9+
def create_feedback_block() -> list[Block]:
10+
"""Create feedback block with thumbs up/down buttons."""
11+
return [
12+
ContextActionsBlock(
13+
elements=[
14+
FeedbackButtonsElement(
15+
action_id="feedback",
16+
positive_button=FeedbackButtonObject(
17+
text="Good Response",
18+
accessibility_label="Submit positive feedback on this response",
19+
value="good-feedback",
20+
),
21+
negative_button=FeedbackButtonObject(
22+
text="Bad Response",
23+
accessibility_label="Submit negative feedback on this response",
24+
value="bad-feedback",
25+
),
26+
)
27+
]
28+
)
29+
]

openai-agents-sdk/listeners/views/issue_modal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def handle_issue_submission(ack: Ack, body: dict, client: WebClient, logger: Log
5050
result = Runner.run_sync(casey_agent, input=user_message, context=deps)
5151

5252
# Post the response in thread with feedback buttons
53-
feedback_blocks = create_feedback_block(thread_ts)
53+
feedback_blocks = create_feedback_block()
5454
response_blocks = [
5555
{
5656
"type": "section",

0 commit comments

Comments
 (0)