Skip to content

added tools filtering#2741

Open
blublinsky wants to merge 1 commit intoopenshift:mainfrom
blublinsky:tools-filtering
Open

added tools filtering#2741
blublinsky wants to merge 1 commit intoopenshift:mainfrom
blublinsky:tools-filtering

Conversation

@blublinsky
Copy link
Contributor

Description

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

@openshift-ci openshift-ci bot requested review from onmete and tisnik February 10, 2026 10:39
@openshift-ci
Copy link

openshift-ci bot commented Feb 10, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bparees for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@blublinsky
Copy link
Contributor Author

/retest

Copy link
Contributor

@onmete onmete left a comment

Choose a reason for hiding this comment

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

A couple of high-level items.

top_k: Number of tools to retrieve
threshold: Minimum similarity threshold for filtering results
"""
self.embed_model = embed_model or "sentence-transformers/all-mpnet-base-v2"
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be configurable for now. It needs to use the hardcoded value of embedding that we have baked in the image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not. We already have this config integrated with the operator

Copy link
Contributor

Choose a reason for hiding this comment

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

Because it would fail in disconnected environments. Why do we need to support the embedding model switch?

user_token,
client_headers,
allowed_tool_names=filtered_tool_names,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

After this method identifies which tools are relevant, it opens new MCP connections to re-fetch those same tools (_gather_and_populate_tools with allowed_tool_names). Why not cache the StructuredTool objects from the initial population and return those directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question.
The issue is that tools have authentication baked in. We need to refetch them with a new authentication to make calls correct

Without this lock, one user's client tools could leak into another user's
filtered results.
"""
return asyncio.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

So the lock is here basically because of the requests with client headers, right?
Client headers are an edge case - a minority of requests, for a minority of server configurations. And the current OLS (UI) is not supporting that.
I really don't like that it affects the architecture of implementation this much.

See this scenario:

  • Index contains: get_pods (k8s-auth) + github_create_pr (client-auth)
  • Query: "create a pull request"
  • ToolsRAG returns: github_create_pr (most relevant)
  • Client didn't send GitHub headers this time
  • Tool gets dropped -> empty result
    The user gets nothing, even though get_pods was in the index and accessible. The most relevant tool won the ranking but was inaccessible, and it pushed out the tools that were actually available.

I think we need static index for tools that are ALWAYS accessible and ANOTHER one for client tools which will be added based on the request headers (and then combine/filter results).
Then both indexes are static, hence no need for lock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The lock is only for mcp_headers. If they are not present, there is no lock. So if you consider mcp_headers an edge case, so is the lock

self.alpha = alpha
self.top_k = top_k
self.threshold = threshold
self.embedding_model = SentenceTransformer(embed_model)
Copy link
Contributor

Choose a reason for hiding this comment

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

We are creating a second instance of the same embedding model we have for RAG. We need to reuse that or at least confirm the library itself is handling that, to not load another ~400MB into memory.

Copy link
Contributor Author

@blublinsky blublinsky Feb 10, 2026

Choose a reason for hiding this comment

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

fixed in config

@blublinsky
Copy link
Contributor Author

/retest

@blublinsky blublinsky force-pushed the tools-filtering branch 2 times, most recently from f7d057c to 70904be Compare February 10, 2026 21:32
@blublinsky
Copy link
Contributor Author

/retest

1 similar comment
@blublinsky
Copy link
Contributor Author

/retest

@blublinsky blublinsky requested a review from onmete February 11, 2026 11:12
@blublinsky blublinsky force-pushed the tools-filtering branch 3 times, most recently from 805285d to 8aa9c0a Compare February 12, 2026 08:53
@blublinsky
Copy link
Contributor Author

/retest

@blublinsky blublinsky force-pushed the tools-filtering branch 3 times, most recently from 5e4f971 to 5b0818a Compare February 12, 2026 17:07
@blublinsky
Copy link
Contributor Author

/retest

@blublinsky blublinsky force-pushed the tools-filtering branch 4 times, most recently from 9e3954b to 14a9bac Compare February 13, 2026 12:18
@blublinsky
Copy link
Contributor Author

/override "ci/prow/e2e-ols-cluster"
Error is unrelated to the code

@openshift-ci
Copy link

openshift-ci bot commented Feb 13, 2026

@blublinsky: Overrode contexts on behalf of blublinsky: ci/prow/e2e-ols-cluster

Details

In response to this:

/override "ci/prow/e2e-ols-cluster"
Error is unrelated to the code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci
Copy link

openshift-ci bot commented Feb 13, 2026

@blublinsky: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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