Skip to content

Conversation

@zhaozuy
Copy link
Contributor

@zhaozuy zhaozuy commented Nov 19, 2025

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…is None but request is a session request, raise 400 error

- change session api transform's transform_request to never return
  request field in output (previously used to pass session_manager
- change handler code to only take raw_request as a parameter and use
  new utility function get_session_manager
- add new integration tests for expected errors when sessions is
  disabled
@Lokiiiiii
Copy link

Logic looks good to me in general. I want to understand the CX before we move further. Can you add docs/examples to help understand the CX ?

@zhaozuy zhaozuy changed the base branch from toggle-sticky-routing to main December 3, 2025 00:11
…ds into custom-session-handlers

Signed-off-by: Zuyi Zhao <[email protected]>
- Fix session ID injection logic to work with default session manager
  - Changed conditional from elif to separate if statements
  - Session ID now properly injected into request body when session_id_path is specified
  - Validation and injection can now happen independently

- Update unit tests to match refactored transform API
  - Remove import of non-existent _validate_session_if_present function
  - Update test signatures to match _process_session_request parameters
  - Add missing SessionRequest import
  - Replace outdated test logic with current implementation

- Add integration tests for session_id_path injection feature
  - Test session ID injection into flat and nested request body paths
  - Test injection with multiple requests and different sessions
  - Verify existing body fields are preserved during injection
- Rename session_id_path to request_session_id_path in stateful_session_manager
- Rename session_id_path to response_session_id_path in register handlers
- Add docstring clarifying request_session_id_path usage
- Provide default content messages for create/close session handlers
- Remove specific engine references (vLLM, TGI) from documentation
- Delete obsolete test_registration.py
- Improve integration tests
@zhaozuy zhaozuy marked this pull request as ready for review December 6, 2025 00:24
Copy link

@Lokiiiiii Lokiiiiii left a comment

Choose a reason for hiding this comment

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

Summarizing -

  1. The parameter names for the handlers are un-intuitive. I recommend renaming it to be obvious in terms of the functionality or the input the developer needs to provide - path_to_session_id_in_incoming_request or something similar.
  2. The documentation has inconsistent ordering of decorators. This will cause issues when overriding handlers.
  3. We need to improve the defaults and documentation needs to indicate defaults for handler arguments

# Register custom close session handler
@register_close_session_handler(
request_shape={
"session_id": 'headers."X-Amzn-SageMaker-Session-Id"' # Extract from header

Choose a reason for hiding this comment

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

Within sagemaker.sessions X-Amzn-SageMaker-Session-Id should be the default. We should remove this from the documentation for ease of understanding.

capacity: int
session_id: Optional[str] = None

@register_create_session_handler(

Choose a reason for hiding this comment

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

I see inconsistent ordering of decorators.

I believe it is supposed to be reversed ie.., handlers should be registered before FastAPI route configurations ?

ref: https://github.com/vllm-project/vllm/blob/6af70e11a0a3cb7109ce904e23ff90c73f573ef0/vllm/entrypoints/sagemaker/routes.py#L66-L72

# Register custom create session handler
@register_create_session_handler(
request_shape={
"capacity": "`1024`" # JMESPath literal value

Choose a reason for hiding this comment

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

Is this a required new field ? Is there going to be a default ?


@register_create_session_handler(
request_shape={
"capacity": "`1024`",

Choose a reason for hiding this comment

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

Why is this needed ?

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.

2 participants