Skip to content

use metadata from SessionMessage to propagate related_request_id #591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 63 commits into from
May 2, 2025

Conversation

ihrpr
Copy link
Contributor

@ihrpr ihrpr commented Apr 27, 2025

Refactoring the way we handle related request IDs in the streamable HTTP transport. Previously, we were adding _meta fields to notification parameters to link notifications to their triggering requests. This approach was fragile and inconsistent
with how other transports handle message metadata.

Changes

  • Moves related_request_id propagation from _meta field to proper SessionMessage
    metadata
  • Updates the shared session module to pass related request ID through SessionMessage
    metadata
  • Removes the custom _meta field handling from streamable HTTP transport
  • Updates tests to reflect the new approach

Note: stacked on top of #590

Improves related request id handling in #553

bhosmer-ant
bhosmer-ant previously approved these changes May 1, 2025
Copy link
Contributor

@bhosmer-ant bhosmer-ant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, one question inline

session_message.metadata is not None
and isinstance(
session_message.metadata,
ServerMessageMetadata,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might they be passing their own object (say with added fields) that still has a related_request_id? Not sure the SDK as currently implemented would be capable of handling that (without hacking anyway), but flagging in case we want to relax this to a hasattr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's actually the reason why typed metadata was introduced, before I was using meta field in the message, which was quite bad

dsp-ant
dsp-ant previously approved these changes May 2, 2025
Base automatically changed from ihrpr/memory-stream-item-type to main May 2, 2025 13:29
@ihrpr ihrpr dismissed stale reviews from dsp-ant and bhosmer-ant May 2, 2025 13:29

The base branch was changed.

@ihrpr ihrpr merged commit cf8b66b into main May 2, 2025
9 checks passed
@ihrpr ihrpr deleted the ihrpr/use-session-message-for-related-request branch May 2, 2025 13:35
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.

3 participants