fix(agent): remove unused RunnableByViewer gate blocking viewer chat
The runnable_by_viewer field was never populated for built-in agents, so TenantRoleViewer users always hit 403 on agent-chat. Drop the field and RBAC check so agent-chat matches knowledge-chat access for viewers.
This commit is contained in:
@@ -583,28 +583,6 @@ func (h *Handler) AgentQA(c *gin.Context) {
|
||||
agentModeEnabled, reqCtx.customAgent.Config.AgentMode)
|
||||
}
|
||||
|
||||
// Tenant-RBAC gate: block Viewers from running agents whose author
|
||||
// has cleared RunnableByViewer. The flag exists so an admin can mark
|
||||
// an agent as "internal tools only" without turning every viewer
|
||||
// into a contributor. Gated behind cfg.Tenant.EnableRBAC so the
|
||||
// check is dormant during the rollout window — same pattern as
|
||||
// middleware/rbac.go.
|
||||
if agentModeEnabled && reqCtx.customAgent != nil && !reqCtx.customAgent.RunnableByViewer {
|
||||
role := types.TenantRoleFromContext(reqCtx.ctx)
|
||||
if !role.HasPermission(types.TenantRoleContributor) {
|
||||
if h.config != nil && h.config.Tenant.IsRBACEnforced() {
|
||||
logger.Warnf(reqCtx.ctx,
|
||||
"[rbac] agent run blocked: viewer cannot run runnable_by_viewer=false agent: agent=%s role=%s",
|
||||
reqCtx.customAgent.ID, role)
|
||||
c.Error(errors.NewForbiddenError("Forbidden: this agent is restricted to contributors and above"))
|
||||
return
|
||||
}
|
||||
logger.Warnf(reqCtx.ctx,
|
||||
"[rbac] agent run would be blocked (logged, not enforced): agent=%s role=%s",
|
||||
reqCtx.customAgent.ID, role)
|
||||
}
|
||||
}
|
||||
|
||||
// Sanity gate: agent mode requires a resolved CustomAgent. If we got
|
||||
// here with agent_enabled=true but agent_id missing/unresolvable, the
|
||||
// AgentQA service will fail deep inside the async goroutine with a
|
||||
|
||||
Reference in New Issue
Block a user