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:
@@ -75,25 +75,6 @@ type CustomAgent struct {
|
||||
TenantID uint64 `yaml:"tenant_id" json:"tenant_id" gorm:"primaryKey"`
|
||||
// Created by user ID
|
||||
CreatedBy string `yaml:"created_by" json:"created_by" gorm:"type:varchar(36)"`
|
||||
// RunnableByViewer controls whether users with TenantRoleViewer can
|
||||
// run this agent IN AGENT MODE (i.e. with tools, MCP, sandboxed code
|
||||
// execution, etc.). Plain RAG / Wiki QA sessions against the same
|
||||
// agent are unaffected — they don't invoke tools, so restricting
|
||||
// them buys no security and would just block Viewer consumption of
|
||||
// published agents. Defaults to true; admins toggle it off for
|
||||
// agents whose tools should be restricted to contributors and above.
|
||||
//
|
||||
// Enforcement lives in handler/session/qa.go's AgentQA, gated behind
|
||||
// cfg.Tenant.EnableRBAC like every other PR2 check.
|
||||
//
|
||||
// Note: no GORM `default:true` tag here. With a plain `bool` field that
|
||||
// tag causes GORM to treat Go's zero value (false) as "unspecified" and
|
||||
// silently rewrite it to the DB default (true) on insert — preventing
|
||||
// admins from ever creating an agent with viewer-runtime disabled. The
|
||||
// column-level DEFAULT TRUE on the database side still covers rows
|
||||
// inserted by raw SQL / migrations; GORM Create always writes the
|
||||
// explicit struct value.
|
||||
RunnableByViewer bool `yaml:"runnable_by_viewer" json:"runnable_by_viewer"`
|
||||
|
||||
// Agent configuration
|
||||
Config CustomAgentConfig `yaml:"config" json:"config" gorm:"type:json"`
|
||||
|
||||
Reference in New Issue
Block a user