diff --git a/internal/store/context.go b/internal/store/context.go index 4994288e..a8a174d2 100644 --- a/internal/store/context.go +++ b/internal/store/context.go @@ -29,6 +29,8 @@ const ( SharedKGKey contextKey = "goclaw_shared_kg" // ShellDenyGroupsKey holds per-agent shell deny group overrides. ShellDenyGroupsKey contextKey = "goclaw_shell_deny_groups" + // AgentKeyKey is the context key for the agent key/name (string identifier, e.g. "default"). + AgentKeyKey contextKey = "goclaw_agent_key" // TenantIDKey is the context key for the tenant UUID. TenantIDKey contextKey = "goclaw_tenant_id" // CrossTenantKey indicates the caller has cross-tenant access (owner/system admin). @@ -89,6 +91,19 @@ func AgentTypeFromContext(ctx context.Context) string { return "" } +// WithAgentKey returns a new context with the agent key/name (string identifier). +func WithAgentKey(ctx context.Context, key string) context.Context { + return context.WithValue(ctx, AgentKeyKey, key) +} + +// AgentKeyFromContext extracts the agent key from context. Returns "" if not set. +func AgentKeyFromContext(ctx context.Context) string { + if v, ok := ctx.Value(AgentKeyKey).(string); ok { + return v + } + return "" +} + // WithSenderID returns a new context with the original individual sender ID. func WithSenderID(ctx context.Context, id string) context.Context { return context.WithValue(ctx, SenderIDKey, id)