feat: add ai terminal settings#12208
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 965da167fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| func normalizeModelID(model string) string { | ||
| model = strings.TrimSpace(model) | ||
| if parts := strings.SplitN(model, "/", 2); len(parts) == 2 { | ||
| return parts[1] |
There was a problem hiding this comment.
Preserve slash-containing custom model IDs
Custom/vLLM accounts keep the user-entered model name verbatim except for an optional leading custom/ (agent/app/service/agents.go:2299), so IDs like meta-llama/Llama-3.1-8B-Instruct are valid. This helper strips everything before the first slash for every provider, which turns those common repo-style model IDs into Llama-3.1-8B-Instruct and makes the terminal feature send a model name the backend does not recognize.
Useful? React with 👍 / 👎.
| httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, buildChatCompletionsURL(c.config.BaseURL), bytes.NewReader(body)) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("create request: %w", err) | ||
| } | ||
| httpReq.Header.Set("Authorization", "Bearer "+strings.TrimSpace(c.config.APIKey)) |
There was a problem hiding this comment.
Limit terminal AI to OpenAI-compatible providers
The terminal client always posts an OpenAI Chat Completions request to /v1/chat/completions and authenticates with Authorization: Bearer ..., but the settings UI accepts every saved agent account. Supported providers like anthropic and gemini use different verified APIs in agent/app/provider/verify.go (x-api-key/anthropic-version and :generateContent respectively), so selecting those accounts saves successfully but every AI terminal request will fail at runtime.
Useful? React with 👍 / 👎.
| if (!value) { | ||
| callback(new Error(i18n.global.t('commons.rule.requiredSelect'))); | ||
| return; | ||
| } | ||
| callback(); |
There was a problem hiding this comment.
Reject unverified agent accounts here
This validator only checks that an account ID is present. However, agent/utils/terminal/ai/config_runtime.go:138-146 rejects any selected account with Verified == false unless the provider skips verification, so choosing one of the N/A entries in this list leaves the UI in an “enabled” state while new terminals silently disable the interceptor instead of generating commands.
Useful? React with 👍 / 👎.
| if isEnterInput(decodeBytes) { | ||
| if generated, ok := sws.aiInterceptor.HandleEnter(); ok { | ||
| sws.sendWebsocketInputCommandToSshSessionStdinPipe(append([]byte{lineClearControl}, []byte(generated)...)) | ||
| continue | ||
| } |
There was a problem hiding this comment.
Consume AI-triggered Enter when generation fails
This branch falls back to sending the original Enter to the shell whenever HandleEnter() returns ok == false, but that method also returns false for AI-side failures (refresh errors, generator creation errors, request timeouts, empty prompts). Because the prefix field accepts any visible ASCII token, a failed //ai ... request becomes an attempted /ai execution on Unix instead of being safely swallowed; the same issue exists in ws_local_session.go.
Useful? React with 👍 / 👎.
No description provided.