Skip to content

Comments

feat: added auth injection for LLM runs in agent#313

Closed
satti-hari-krishna-reddy wants to merge 6 commits intoShuffle:mainfrom
satti-hari-krishna-reddy:my-fix
Closed

feat: added auth injection for LLM runs in agent#313
satti-hari-krishna-reddy wants to merge 6 commits intoShuffle:mainfrom
satti-hari-krishna-reddy:my-fix

Conversation

@satti-hari-krishna-reddy
Copy link
Collaborator

@satti-hari-krishna-reddy satti-hari-krishna-reddy commented Feb 4, 2026

What's changed

  • Added environment variable injection (AI_API_KEY/URL) for AI Agent execution.

Copy link
Member

@frikky frikky left a comment

Choose a reason for hiding this comment

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

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
Copy link
Member

@frikky frikky Feb 4, 2026

Choose a reason for hiding this comment

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

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.

@satti-hari-krishna-reddy satti-hari-krishna-reddy marked this pull request as draft February 5, 2026 12:16
@satti-hari-krishna-reddy satti-hari-krishna-reddy marked this pull request as ready for review February 5, 2026 15:01
Copy link
Member

@frikky frikky left a comment

Choose a reason for hiding this comment

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

:)

ctx := context.Background()

// Track AI credits for cloud (only on first call)
if project.Environment == "cloud" && !createNextActions {
Copy link
Member

Choose a reason for hiding this comment

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

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 != "" {
Copy link
Member

Choose a reason for hiding this comment

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

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 {
Copy link
Member

Choose a reason for hiding this comment

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

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.

@frikky
Copy link
Member

frikky commented Feb 8, 2026

Fundamental understanding problem:

  • IF they have credentials, we always use them
  • Ours are fallback, and we only track AI usage IF ours are used. Also, we may want to track Token usage rather than just "+1" lol

@satti-hari-krishna-reddy satti-hari-krishna-reddy marked this pull request as draft February 8, 2026 11:03
@satti-hari-krishna-reddy
Copy link
Collaborator Author

@frikky Closing this and continuing here #321

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