Skip to content

(feat): temporal agent works with the agentex ui#153

Open
levilentz wants to merge 1 commit intomainfrom
bug/temporal-chat-ui-fix
Open

(feat): temporal agent works with the agentex ui#153
levilentz wants to merge 1 commit intomainfrom
bug/temporal-chat-ui-fix

Conversation

@levilentz
Copy link
Contributor

@levilentz levilentz commented Feb 24, 2026

When creating a temporal chatbot updates are not streamed to the UI. that requires constant refreshing of the UI to see new messages. This fix aligns these and ensures that the temporal-based chatbots will work in the agentex UI.

Greptile Summary

This PR enables real-time UI updates for temporal-based chatbots by publishing Redis stream events whenever task messages are created or updated. Previously, the TaskMessageService only persisted messages to MongoDB without notifying subscribed UI clients, requiring manual page refreshes to see new messages.

  • TaskMessageService now publishes StreamTaskMessageFull events to Redis on every append_message, append_messages, update_message, and update_messages call, using the same task:{task_id} topic that the SSE stream endpoint reads from.
  • New stream_repository dependency injected into TaskMessageService, following the same pattern already used by AgentTaskService.
  • Error handling in _publish_message_full_event catches and logs exceptions without disrupting the core message CRUD operations.
  • All test fixtures updated across unit and integration tests to pass the new stream_repository parameter.

Confidence Score: 4/5

  • This PR is safe to merge with low risk — it adds fire-and-forget Redis publishing with proper error handling.
  • The changes are well-scoped and follow established patterns from AgentTaskService. The error handling in _publish_message_full_event prevents stream failures from breaking message operations. All test fixtures are properly updated. The only consideration is potential duplicate Redis events when the ACP streaming path (which already yields NDJSON) also triggers these new Redis publishes, but this is harmless and actually beneficial for SSE subscribers.
  • agentex/src/domain/services/task_message_service.py — core logic change with new Redis stream publishing on all message mutation paths

Important Files Changed

Filename Overview
agentex/src/domain/services/task_message_service.py Core change: adds Redis stream publishing via _publish_message_full_event to all message create/update paths. New stream_repository dependency injected. Exception handling prevents stream failures from breaking message operations. Hardcoded index=0 is acceptable for standalone full events.
agentex/tests/fixtures/services.py Updated factory and fixture to pass stream_repository/redis_stream_repository to TaskMessageService. Keyword argument names corrected to match the constructor.
agentex/tests/integration/fixtures/integration_client.py Integration fixture updated to pass stream_repository from isolated repositories when constructing TaskMessageService. Aligns with the new constructor signature.
agentex/tests/unit/services/test_task_message_service.py Test fixture updated to pass redis_stream_repository to TaskMessageService. No test logic changes needed since stream publishing is fire-and-forget with error swallowing.
agentex/tests/unit/use_cases/test_agents_acp_use_case.py Test fixture updated to pass redis_stream_repository to TaskMessageService constructor. No test logic changes required.

Sequence Diagram

sequenceDiagram
    participant Temporal as Temporal Agent
    participant TMS as TaskMessageService
    participant MongoDB as MongoDB
    participant Redis as Redis Stream
    participant SSE as SSE Endpoint
    participant UI as Agentex UI

    Temporal->>TMS: append_message(task_id, content)
    TMS->>MongoDB: create(task_message)
    MongoDB-->>TMS: created_message
    TMS->>Redis: send_data(task:{task_id}, StreamTaskMessageFull)
    Note over Redis: New! Previously missing
    TMS-->>Temporal: created_message

    UI->>SSE: GET /tasks/{task_id}/stream
    SSE->>Redis: read_messages(task:{task_id})
    Redis-->>SSE: StreamTaskMessageFull event
    SSE-->>UI: SSE event (real-time update)
Loading

Last reviewed commit: bcd22b3

(5/5) You can turn off certain types of comments like style here!

@levilentz levilentz requested a review from a team as a code owner February 24, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant