-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: reuse previous mcp tool listings where possible #3710
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Gordon Sim <[email protected]>
llama_stack/providers/inline/agents/meta_reference/responses/streaming.py
Outdated
Show resolved
Hide resolved
tests/unit/providers/agents/meta_reference/test_openai_responses.py
Outdated
Show resolved
Hide resolved
assert isinstance(inference_messages[i], OpenAIDeveloperMessageParam) | ||
|
||
|
||
async def test_prepend_previous_response_basic(openai_responses_impl, mock_responses_store): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG!
# Handle all mcp tool lists from previous response that are still valid: | ||
for tool in self.ctx.tool_context.previous_tool_listings: | ||
async for evt in self._reuse_mcp_list_tools(tool, output_messages): | ||
yield evt | ||
# Process all remaining tools (including MCP tools) and emit streaming events | ||
if self.ctx.tool_context.tools_to_process: | ||
async for stream_event in self._process_tools(self.ctx.tool_context.tools_to_process, output_messages): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we still have all this logic in _process_tools
? and maybe rename the existing function to _process_new_tools
What does this PR do?
This PR checks whether, if a previous response is linked, there are mcp_list_tools objects that can be reused instead of listing the tools explicitly every time.
Closes #3106
Test Plan
Tested manually.
Added unit tests to cover new behaviour.