-
Notifications
You must be signed in to change notification settings - Fork 184
Accept passthrough headers in agent execute #4364
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?
Accept passthrough headers in agent execute #4364
Conversation
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.
spotless needs to apply
55ee4c9 to
856c4fa
Compare
856c4fa to
acac26b
Compare
Signed-off-by: Jiaping Zeng <[email protected]>
Signed-off-by: Jiaping Zeng <[email protected]>
4327051 to
c14d0c5
Compare
| return Collections.emptyMap(); | ||
| } | ||
|
|
||
| String headersJson = parameters.get(CommonValue.MCP_REQUEST_HEADERS); |
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.
Is the expectation that header contains a json? this seems a anti pattern.
| Duration connectionTimeout = Duration.ofSeconds(super.getConnectorClientConfig().getConnectionTimeout()); | ||
| Duration readTimeout = Duration.ofSeconds(super.getConnectorClientConfig().getReadTimeout()); | ||
|
|
||
| Map<String, String> mergedHeaders = new HashMap<>(); |
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.
Creating a mergedHeaders might be unnecessary. Request header could be directly added to builder while creating headerConfig
| if (connector.getDecryptedHeaders() != null) { | ||
| mergedHeaders.putAll(connector.getDecryptedHeaders()); | ||
| } | ||
| if (requestHeaders != null) { | ||
| mergedHeaders.putAll(requestHeaders); | ||
| } |
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.
Same as above.
| * @param request RestRequest containing the MCP headers | ||
| * @param agentInput AgentMLInput to add the headers to | ||
| */ | ||
| public static void addMcpRequestHeaders(RestRequest request, AgentMLInput agentInput) { |
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.
Add unit test.
| String headersJson = gson.toJson(headers); | ||
| RemoteInferenceInputDataSet inputDataSet = (RemoteInferenceInputDataSet) agentInput.getInputDataset(); | ||
| if (inputDataSet != null && inputDataSet.getParameters() != null) { | ||
| inputDataSet.getParameters().put(CommonValue.MCP_REQUEST_HEADERS, headersJson); |
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.
It seems we are overriding parameters to also include headers. Can we rather create a new header field to RemoteInferenceInputDataSet for headers?
Description
Create MCP client on each execute request + forward headers to MCP connector
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
Accepted headers:
Sample request:
Response: