Repository navigation
Description
What happened?
Since #5421, the LiteLLM proxy endpoints in the access-control-service (/api/chat/{path}, /api/models) are guarded by @RolesAllowed({"REGULAR", "ADMIN"}): they only accept a Texera user JWT, and the proxy injects LITELLM_MASTER_KEY into the downstream request to LiteLLM (AccessControlResource.scala).
The agent-service was not updated for this. createAgentInstance (agent-service/src/server.ts) still builds its OpenAI client with the static env.LLM_API_KEY, which defaults to the literal string "dummy" (agent-service/src/config/env.ts). The proxy rejects Bearer dummy with 401 Unauthorized, so on current main every agent generation call fails in the default (proxied) deployment — agent creation succeeds, but the agent can never produce a response.
sequenceDiagram
participant FE as Frontend (user JWT)
participant AS as agent-service
participant ACS as access-control-service (LiteLLM proxy)
participant LLM as LiteLLM
FE->>AS: create agent (userToken = user JWT) ✅
FE->>AS: send message
AS->>ACS: POST /api/chat/completions<br/>Authorization: Bearer dummy ❌
ACS-->>AS: 401 Unauthorized (REGULAR/ADMIN JWT required)
Note over ACS,LLM: never reached — proxy would inject<br/>LITELLM_MASTER_KEY downstream
AS-->>FE: agent turn fails
Expected: the agent-service already holds the delegating user's JWT (userToken from the create-agent request), so it should present that JWT to the proxy. An explicitly configured LLM_API_KEY should still take precedence for direct, unproxied LiteLLM deployments.
How to reproduce?
- Deploy current
mainwith the standard topology: agent-serviceLLM_ENDPOINTpointing at the access-control-service proxy (:9096, the default in k8s/single-node). - Log in as a REGULAR user and create an agent (
POST /api/agentswithuserToken) — this succeeds. - Send a message to the agent over the websocket (
/api/agents/:id/react). - The turn fails: the agent-service gets 401 from
POST /api/chat/completionsbecause it sentAuthorization: Bearer dummy.
Equivalent check without the agent: curl -H "Authorization: Bearer dummy" http://localhost:9096/api/models → 401, while the same request with a valid REGULAR-user JWT → 200.
Version/Branch
1.3.0-incubating-SNAPSHOT (main)
Commit Hash (Optional)
07ca5d4 (regression introduced by 24e5b70, #5421)
What browsers are you seeing the problem on?
No response (backend issue, browser-independent)
Relevant log output
# agent-service (representative)
AI_APICallError: Unauthorized
statusCode: 401
url: http://access-control-service-svc:9096/api/chat/completions
Activity
fix(agent-service): authenticate to the LLM proxy as the delegating u…
fix(agent-service): authenticate to the LLM proxy as the delegating u…
fix(agent-service): authenticate to the LLM proxy as the delegating u…
fix(agent-service): authenticate to the LLM proxy as the delegating u…