Skip to content
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

feat: pass supplemental contexts only for token client #697

Merged

Conversation

francescoopiccoli
Copy link
Contributor

@francescoopiccoli francescoopiccoli commented Jan 3, 2025

Problem

From version v0.0.14 to v0.0.15 of lsp-codewhisper, we introduced supplementalContexts universally, regardless of whether it's a iam or token client. However, supplementalContext is only accepted by backend when using token authentication. When using iam authentication, the parameter is not accepted, thus we need to introduce authentication specific logic to deal with supplementalContext.

bearer token based client: https://github.com/aws/language-servers/blob/main/server/aws-lsp-codewhisperer/src/client/token/bearer-token-service.json#L2707
iam based client: https://github.com/aws/language-servers/blob/main/server/aws-lsp-codewhisperer/src/client/sigv4/service.json

Solution

Introducing client specific logic to pass supplementalContext data

I tested the solution via the CodeWhisperer Server Token debug config, and in the spawned vscode client I tried using inline completion.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

filePath: v.filePath,
}))
: [],
...(codeWhispererService instanceof CodeWhispererServiceToken && {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to introduce separate if for this below, fetchSupplementalContext only for token-based server and set requestContext.supplementalContexts.

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 idea, I implemented it, I utilized supplementalContextPromise construct to optimize performance and run in parallel, otherwise some tests were failing (e.g. Case 4. Inflight session is closed by subsequent completion request), due to a higher timeToFirstRecommendation value (from 1260, to 2500)

@@ -406,7 +409,8 @@ export const CodewhispererServerFactory =
classifierResult: autoTriggerResult?.classifierResult,
classifierThreshold: autoTriggerResult?.classifierThreshold,
credentialStartUrl: credentialsProvider.getConnectionMetadata?.()?.sso?.startUrl ?? undefined,
supplementalMetadata: supplementalContext,
supplementalMetadata:
codeWhispererService instanceof CodeWhispererServiceToken ? supplementalContext : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

Then this check here would not be needed.

@francescoopiccoli francescoopiccoli marked this pull request as ready for review January 3, 2025 14:19
@francescoopiccoli francescoopiccoli requested a review from a team as a code owner January 3, 2025 14:19
@francescoopiccoli francescoopiccoli changed the title Pass supplemental contexts only for token client feat: pass supplemental contexts only for token client Jan 7, 2025
@francescoopiccoli francescoopiccoli merged commit 7242835 into main Jan 7, 2025
6 checks passed
@francescoopiccoli francescoopiccoli deleted the frapicc/supplemental-contexts-only-with-token-auth branch January 7, 2025 17:05
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