Skip to content

Conversation

@kevin-shelaga
Copy link

No description provided.

Signed-off-by: kevin-shelaga <kevin.shelaga@solo.io>
Copilot AI review requested due to automatic review settings December 23, 2025 18:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements user ID passthrough functionality for OpenAI API requests to enable better usage tracking and rate limiting. The implementation uses Python's contextvars to pass the user_id through async call chains without modifying function signatures.

Key Changes:

  • Introduced a context variable system to store and retrieve user_id across async boundaries
  • Modified OpenAI/Azure OpenAI integration to include user_id parameter in API requests when available
  • Updated agent executor to set user_id in context from incoming request parameters

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
python/packages/kagent-adk/src/kagent/adk/_context.py New module providing context variable functions (set_user_id, get_user_id, clear_user_id) for passing user_id through async call chains
python/packages/kagent-adk/src/kagent/adk/models/_openai.py Modified generate_content_async to retrieve user_id from context and pass it to OpenAI API (applies to both OpenAI and Azure OpenAI)
python/packages/kagent-adk/src/kagent/adk/_agent_executor.py Updated _handle_request to set user_id in context from run_args and ensure cleanup after request processing
python/packages/kagent-adk/tests/unittests/test_context.py New test file with comprehensive coverage of context variable functionality including async isolation tests
python/packages/kagent-adk/tests/unittests/models/test_openai.py Added 6 new test cases covering user passthrough for OpenAI, Azure OpenAI, streaming mode, and edge cases (empty/whitespace user_id)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

kevin-shelaga and others added 2 commits December 23, 2025 13:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Kevin Shelaga <65769106+kevin-shelaga@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Kevin Shelaga <65769106+kevin-shelaga@users.noreply.github.com>
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