feat: added auth injection for LLM runs in agent#313
feat: added auth injection for LLM runs in agent#313satti-hari-krishna-reddy wants to merge 6 commits intoShuffle:mainfrom
Conversation
frikky
left a comment
There was a problem hiding this comment.
Check my suggestion and fix it
shared.go
Outdated
| // This is NOT a good solution, but a good bypass | ||
| if app.Authentication.Required || len(action.AuthenticationId) > 0 { | ||
| // Check if this is from AI Agent - if so, skip the auth logic | ||
| isAiAgent := false |
There was a problem hiding this comment.
So if I make an app that has the field "_shuffle_ai_agent" and set the value to true, then I can pass along the parameters as I want?
Short answer:
- Why can't you just inject it in PrepareSingleAction() directly? Why would it be different if it was ran directly vs if it is ran by the AI Agent? And ALWAYS make sure it sets both the URL AND the apikey? That way it can't ever be sent to the wrong location.
What needs to be verified: Whether the auth is available during runtime of the execution or not. If you force a delay of e.g. 600 seconds you can see this.
| ctx := context.Background() | ||
|
|
||
| // Track AI credits for cloud (only on first call) | ||
| if project.Environment == "cloud" && !createNextActions { |
There was a problem hiding this comment.
Why would it track this here?
We don't even know if we're using our own credentials or not at this point.
| completionRequest.MaxCompletionTokens = 5000 | ||
| } else { | ||
| // For on-prem | ||
| if maxTokens := os.Getenv("AI_MAX_TOKENS"); maxTokens != "" { |
There was a problem hiding this comment.
Why not pre-initialise a variable and reference it rather than constantly parsing ENV?
| if app.Authentication.Required || len(action.AuthenticationId) > 0 { | ||
| // Special handling for OpenAI app when no authentication is provided | ||
| skipAuthBlock := false | ||
| if appId == "5d19dd82517870c68d40cacad9b5ca91" && len(action.AuthenticationId) == 0 { |
There was a problem hiding this comment.
If you are to "skipAuthBlock", can't this code just be... after that next part?
IF they have AI creds, we should always fall back to those.
PS: Don't use appId. It will change. Use the name + version.
|
Fundamental understanding problem:
|
What's changed